Method: Curses.unget_char

Defined in:
ext/curses/curses.c

.unget_char(ch) ⇒ Object

Places ch back onto the input queue to be returned by the next call to Curses.get_char etc.

There is just one input queue for all windows.



4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
# File 'ext/curses/curses.c', line 4740

static VALUE
curses_unget_char(VALUE obj, VALUE ch)
{
    ID id_ord;
    unsigned int c;

    curses_stdscr();
    if (FIXNUM_P(ch)) {
  ungetch(NUM2UINT(ch));
    }
    else {
  StringValue(ch);
  CONST_ID(id_ord, "ord");
  c = NUM2UINT(rb_funcall(ch, id_ord, 0));
#ifdef HAVE_UNGET_WCH
  unget_wch(c);
#else
  if (c > 0xff) {
      rb_raise(rb_eRangeError, "Out of range: %u", c);
  }
  ungetch(c);
#endif
    }
    return Qnil;
}