[前][次][番号順一覧][スレッド一覧]

ruby-changes:15777

From: nobu <ko1@a...>
Date: Mon, 10 May 2010 00:54:41 +0900 (JST)
Subject: [ruby-changes:15777] Ruby:r27706 (trunk): * ext/io/console/console.c (console_set_raw): new method.

nobu	2010-05-10 00:54:17 +0900 (Mon, 10 May 2010)

  New Revision: 27706

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27706

  Log:
    * ext/io/console/console.c (console_set_raw): new method.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/ext/io/console/console.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27705)
+++ ChangeLog	(revision 27706)
@@ -1,5 +1,7 @@
-Mon May 10 00:35:41 2010  Nobuyoshi Nakada  <nobu@r...>
+Mon May 10 00:54:15 2010  Nobuyoshi Nakada  <nobu@r...>
 
+	* ext/io/console/console.c (console_set_raw): new method.
+
 	* ext/io/console/console.c (ttymode): reverted previous commit.
 
 Sun May  9 23:53:14 2010  Nobuyoshi Nakada  <nobu@r...>
Index: ext/io/console/console.c
===================================================================
--- ext/io/console/console.c	(revision 27705)
+++ ext/io/console/console.c	(revision 27706)
@@ -246,7 +246,28 @@
     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)
 {
     return rb_funcall2(io, id_getc, 0, 0);
@@ -520,6 +541,7 @@
 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);
Index: NEWS
===================================================================
--- NEWS	(revision 27705)
+++ NEWS	(revision 27706)
@@ -413,7 +413,9 @@
 * io/console
   * new methods:
     * IO#noecho {|io| }
+    * IO#echo=
     * IO#raw {|io| }
+    * IO#raw!
     * IO#getch
     * IO#winsize
     * IO.console

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]