summaryrefslogtreecommitdiff
path: root/ext/io/console/console.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-09 15:54:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-09 15:54:17 +0000
commitb44618d5e5f531beacd42d4222560981667be572 (patch)
tree186c54735b10681ee85bf1dfec8abbf7b67db66c /ext/io/console/console.c
parent08bf7189f873e74e973eff7cee6540b974720a31 (diff)
* ext/io/console/console.c (console_set_raw): new method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/io/console/console.c')
-rw-r--r--ext/io/console/console.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index a521312e477..7656c66c211 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -246,6 +246,27 @@ console_raw(VALUE io)
return ttymode(io, rb_yield, set_rawmode);
}
+/*
+ * call-seq:
+ * io.raw!
+ *
+ * Enables raw mode.
+ */
+static VALUE
+console_set_raw(VALUE io)
+{
+ conmode t;
+ rb_io_t *fptr;
+ int fd;
+
+ GetOpenFile(io, fptr);
+ fd = GetReadFD(fptr);
+ if (!getattr(fd, &t)) rb_sys_fail(0);
+ set_rawmode(&t);
+ if (!setattr(fd, &t)) rb_sys_fail(0);
+ return io;
+}
+
static VALUE
getc_call(VALUE io)
{
@@ -520,6 +541,7 @@ void
InitVM_console(void)
{
rb_define_method(rb_cIO, "raw", console_raw, 0);
+ rb_define_method(rb_cIO, "raw!", console_set_raw, 0);
rb_define_method(rb_cIO, "getch", console_getch, 0);
rb_define_method(rb_cIO, "echo=", console_set_echo, 1);
rb_define_method(rb_cIO, "echo?", console_echo_p, 0);