ruby-changes:20133
From: kouji <ko1@a...>
Date: Tue, 21 Jun 2011 13:30:27 +0900 (JST)
Subject: [ruby-changes:20133] kouji:r32181 (trunk): * ext/readline/readline.c (readline_getc): applied a patch in
kouji 2011-06-21 13:30:14 +0900 (Tue, 21 Jun 2011) New Revision: 32181 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32181 Log: * ext/readline/readline.c (readline_getc): applied a patch in #3827 by by Akio Tajima <artonx AT yahoo.co.jp>. (see #3827) Modified files: trunk/ChangeLog trunk/ext/readline/readline.c Index: ChangeLog =================================================================== --- ChangeLog (revision 32180) +++ ChangeLog (revision 32181) @@ -1,3 +1,8 @@ +Tue Jun 21 13:25:35 2011 TAKAO Kouji <kouji@t...> + + * ext/readline/readline.c (readline_getc): applied a patch in + #3827 by by Akio Tajima <artonx AT yahoo.co.jp>. (see #3827) + Tue Jun 21 13:16:31 2011 TAKAO Kouji <kouji@t...> * ext/readline/extconf.rb: fixed bug, specify --disable-libedit Index: ext/readline/readline.c =================================================================== --- ext/readline/readline.c (revision 32180) +++ ext/readline/readline.c (revision 32181) @@ -131,6 +131,34 @@ if (!readline_instream) return rl_getc(input); GetOpenFile(readline_instream, ifp); if (rl_instream != ifp->stdio_file) return rl_getc(input); +#if defined(_WIN32) + { + INPUT_RECORD ir; + int n; + static int prior_key = '0'; + for (;;) { + if (prior_key > 0xff) { + prior_key = rl_getc(ifp->stdio_file); + return prior_key; + } + if (PeekConsoleInput((HANDLE)_get_osfhandle(ifp->fd), &ir, 1, &n)) { + if (n == 1) { + if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown) { + prior_key = rl_getc(ifp->stdio_file); + return prior_key; + } else { + ReadConsoleInput((HANDLE)_get_osfhandle(ifp->fd), &ir, 1, &n); + } + } else { + HANDLE h = (HANDLE)_get_osfhandle(ifp->fd); + rb_w32_wait_events(&h, 1, INFINITE); + } + } else { + break; + } + } + } +#endif c = rb_funcall(readline_instream, id_getbyte, 0, 0); if (NIL_P(c)) return EOF; return NUM2CHR(c); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/