Method: Curses::Window#getch

Defined in:
ext/curses/curses.c

#getchObject

Read and returns a character from the window.

See Curses::Key to all the function KEY_* available



2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
# File 'ext/curses/curses.c', line 2531

static VALUE
window_getch(VALUE obj)
{
    struct windata *winp;
    struct wgetch_arg arg;
    int c;

    GetWINDOW(obj, winp);
    arg.win = winp->window;
    rb_thread_call_without_gvl(wgetch_func, (void *)&arg, RUBY_UBF_IO, 0);
    c = arg.c;
    if (c == EOF) return Qnil;
    if (rb_isprint(c)) {
  char ch = (char)c;

  return rb_external_str_new_with_enc(&ch, 1, keyboard_encoding);
    }
    return UINT2NUM(c);
}