aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--NEWS2
-rw-r--r--ext/io/console/console.c22
3 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 398b2b8391..7677a7010f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
-Mon May 10 00:35:41 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon May 10 00:54:15 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/io/console/console.c (console_set_raw): new method.
* ext/io/console/console.c (ttymode): reverted previous commit.
diff --git a/NEWS b/NEWS
index 53e78e9a09..a96ba820e0 100644
--- a/NEWS
+++ b/NEWS
@@ -413,7 +413,9 @@ with all sufficient information, see the ChangeLog file.
* io/console
* new methods:
* IO#noecho {|io| }
+ * IO#echo=
* IO#raw {|io| }
+ * IO#raw!
* IO#getch
* IO#winsize
* IO.console
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index a521312e47..7656c66c21 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);