Method: Curses::Window#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
4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 |
# File 'ext/curses/curses.c', line 4871
static VALUE
window_get_char(VALUE obj)
{
#ifdef HAVE_WGET_WCH
struct windata *winp;
struct wget_wch_arg arg;
GetWINDOW(obj, winp);
arg.win = winp->window;
rb_thread_call_without_gvl(wget_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
struct windata *winp;
struct wgetch_arg arg;
GetWINDOW(obj, winp);
arg.win = winp->window;
rb_thread_call_without_gvl(wgetch_func, (void *)&arg, RUBY_UBF_IO, 0);
if (arg.c > 0xff) {
return INT2NUM(arg.c);
}
else if (arg.c >= 0) {
return keyboard_uint_chr(arg.c);
}
else {
return Qnil;
}
#endif
}
|