Method: Curses.get_char
- Defined in:
- ext/curses/curses.c
.get_char ⇒ Object
Read and returns a character or function key from the window. A single or multibyte character is represented by a String, and a function key is represented by an Integer. Returns nil if no input is ready.
See Curses::Key to all the function KEY_* available
4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 |
# File 'ext/curses/curses.c', line 4811 static VALUE curses_get_char(VALUE obj) { #ifdef HAVE_GET_WCH struct get_wch_arg arg; curses_stdscr(); rb_thread_call_without_gvl(get_wch_func, &arg, RUBY_UBF_IO, 0); switch (arg.retval) { case OK: return keyboard_uint_chr(arg.ch); case KEY_CODE_YES: return key_code_value(arg.ch); } return Qnil; #else int c; curses_stdscr(); rb_thread_call_without_gvl(getch_func, &c, RUBY_UBF_IO, 0); if (c > 0xff) { return INT2NUM(c); } else if (c >= 0) { return keyboard_uint_chr(c); } else { return Qnil; } #endif } |