————————- Initialization ————————-
def addch(ch)
static VALUE curses_addch(VALUE obj, VALUE ch) { curses_stdscr(); addch(NUM2CH(ch)); return Qnil; }
def addstr(str)
static VALUE curses_addstr(VALUE obj, VALUE str) { StringValue(str); str = rb_str_export_locale(str); curses_stdscr(); if (!NIL_P(str)) { addstr(StringValueCStr(str)); } return Qnil; }
static VALUE curses_attroff(VALUE obj, VALUE attrs) { curses_stdscr(); return window_attroff(rb_stdscr,attrs); /* return INT2FIX(attroff(NUM2INT(attrs))); */ }
static VALUE curses_attron(VALUE obj, VALUE attrs) { curses_stdscr(); return window_attron(rb_stdscr,attrs); /* return INT2FIX(attroff(NUM2INT(attrs))); */ }
static VALUE curses_attrset(VALUE obj, VALUE attrs) { curses_stdscr(); return window_attrset(rb_stdscr,attrs); /* return INT2FIX(attroff(NUM2INT(attrs))); */ }
def beep
static VALUE curses_beep(VALUE obj) { #ifdef HAVE_BEEP curses_stdscr(); beep(); #endif return Qnil; }
static VALUE curses_bkgd(VALUE obj, VALUE ch) { #ifdef HAVE_BKGD curses_stdscr(); return (bkgd(NUM2CH(ch)) == OK) ? Qtrue : Qfalse; #else return Qfalse; #endif }
static VALUE curses_bkgdset(VALUE obj, VALUE ch) { #ifdef HAVE_BKGDSET curses_stdscr(); bkgdset(NUM2CH(ch)); #endif return Qnil; }
static VALUE curses_can_change_color(VALUE obj) { curses_stdscr(); return can_change_color() ? Qtrue : Qfalse; }
def cbreak
static VALUE curses_cbreak(VALUE obj) { curses_stdscr(); cbreak(); return Qnil; }
def clear
static VALUE curses_clear(VALUE obj) { curses_stdscr(); wclear(stdscr); return Qnil; }
def ::close_screen
static VALUE curses_close_screen(void) { curses_stdscr(); #ifdef HAVE_ISENDWIN if (!isendwin()) #endif endwin(); rb_stdscr = 0; return Qnil; }
def closed?
static VALUE curses_closed(void) { #ifdef HAVE_ISENDWIN curses_stdscr(); if (isendwin()) { return Qtrue; } return Qfalse; #else rb_notimplement(); #endif }
def clrtoeol
static VALUE curses_clrtoeol(void) { curses_stdscr(); clrtoeol(); return Qnil; }
static VALUE curses_color_content(VALUE obj, VALUE color) { short r,g,b; curses_stdscr(); color_content(NUM2INT(color),&r,&g,&b); return rb_ary_new3(3,INT2FIX(r),INT2FIX(g),INT2FIX(b)); }
static VALUE curses_color_pair(VALUE obj, VALUE attrs) { return INT2FIX(COLOR_PAIR(NUM2INT(attrs))); }
static VALUE curses_curs_set(VALUE obj, VALUE visibility) { #ifdef HAVE_CURS_SET int n; curses_stdscr(); return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil; #else return Qnil; #endif }
static VALUE curses_def_prog_mode(VALUE obj) { #ifdef HAVE_DEF_PROG_MODE curses_stdscr(); return def_prog_mode() == OK ? Qtrue : Qfalse; #else rb_notimplement(); #endif }
def delch
static VALUE curses_delch(VALUE obj) { curses_stdscr(); delch(); return Qnil; }
def delelteln
static VALUE curses_deleteln(VALUE obj) { curses_stdscr(); #if defined(HAVE_DELETELN) || defined(deleteln) deleteln(); #endif return Qnil; }
def doupdate
static VALUE curses_doupdate(VALUE obj) { curses_stdscr(); #ifdef HAVE_DOUPDATE doupdate(); #else refresh(); #endif return Qnil; }
def echo
static VALUE curses_echo(VALUE obj) { curses_stdscr(); echo(); return Qnil; }
def flash
static VALUE curses_flash(VALUE obj) { #ifdef HAVE_FLASH curses_stdscr(); flash(); #endif return Qnil; }
def getch
static VALUE curses_getch(VALUE obj) { int c; rb_read_check(stdin); curses_stdscr(); c = getch(); if (c == EOF) return Qnil; if (rb_isprint(c)) { char ch = (char)c; return rb_locale_str_new(&ch, 1); } return UINT2NUM(c); }
static VALUE curses_getmouse(VALUE obj) { struct mousedata *mdata; VALUE val; curses_stdscr(); val = Data_Make_Struct(cMouseEvent,struct mousedata, 0,curses_mousedata_free,mdata); mdata->mevent = (MEVENT*)xmalloc(sizeof(MEVENT)); return (getmouse(mdata->mevent) == OK) ? val : Qnil; }
def getstr
static VALUE curses_getstr(VALUE obj) { char rtn[1024]; /* This should be big enough.. I hope */ curses_stdscr(); rb_read_check(stdin); #if defined(HAVE_GETNSTR) getnstr(rtn,1023); #else getstr(rtn); #endif return rb_locale_str_new_cstr(rtn); }
static VALUE curses_has_colors(VALUE obj) { curses_stdscr(); return has_colors() ? Qtrue : Qfalse; }
def inch
static VALUE curses_inch(VALUE obj) { curses_stdscr(); return CH2FIX(inch()); }
static VALUE curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b) { /* may have to raise exception on ERR */ curses_stdscr(); return (init_color(NUM2INT(color),NUM2INT(r), NUM2INT(g),NUM2INT(b)) == OK) ? Qtrue : Qfalse; }
static VALUE curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b) { /* may have to raise exception on ERR */ curses_stdscr(); return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse; }
def ::init_screen
static VALUE curses_init_screen(void) { rb_secure(4); if (rb_stdscr) return rb_stdscr; initscr(); if (stdscr == 0) { rb_raise(rb_eRuntimeError, "can't initialize curses"); } clear(); rb_stdscr = prep_window(cWindow, stdscr); return rb_stdscr; }
def insch(ch)
static VALUE curses_insch(VALUE obj, VALUE ch) { curses_stdscr(); insch(NUM2CH(ch)); return Qnil; }
def insertln
static VALUE curses_insertln(VALUE obj) { curses_stdscr(); #if defined(HAVE_INSERTLN) || defined(insertln) insertln(); #endif return Qnil; }
def keyname
static VALUE curses_keyname(VALUE obj, VALUE c) { #ifdef HAVE_KEYNAME int cc = curses_char(c); const char *name; curses_stdscr(); name = keyname(cc); if (name) { return rb_str_new_cstr(name); } else { return Qnil; } #else return Qnil; #endif }
static VALUE curses_mouseinterval(VALUE obj, VALUE interval) { curses_stdscr(); return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse; }
static VALUE curses_mousemask(VALUE obj, VALUE mask) { curses_stdscr(); return INT2NUM(mousemask(NUM2UINT(mask),NULL)); }
def nl
static VALUE curses_nl(VALUE obj) { curses_stdscr(); nl(); return Qnil; }
def nocbreak
static VALUE curses_nocbreak(VALUE obj) { curses_stdscr(); nocbreak(); return Qnil; }
def noecho
static VALUE curses_noecho(VALUE obj) { curses_stdscr(); noecho(); return Qnil; }
def nonl
static VALUE curses_nonl(VALUE obj) { curses_stdscr(); nonl(); return Qnil; }
def noraw
static VALUE curses_noraw(VALUE obj) { curses_stdscr(); noraw(); return Qnil; }
static VALUE curses_pair_content(VALUE obj, VALUE pair) { short f,b; curses_stdscr(); pair_content(NUM2INT(pair),&f,&b); return rb_ary_new3(2,INT2FIX(f),INT2FIX(b)); }
static VALUE curses_pair_number(VALUE obj, VALUE attrs) { curses_stdscr(); return INT2FIX(PAIR_NUMBER(NUM2INT(attrs))); }
def raw
static VALUE curses_raw(VALUE obj) { curses_stdscr(); raw(); return Qnil; }
def refresh
static VALUE curses_refresh(VALUE obj) { curses_stdscr(); refresh(); return Qnil; }
static VALUE curses_reset_prog_mode(VALUE obj) { #ifdef HAVE_RESET_PROG_MODE curses_stdscr(); return reset_prog_mode() == OK ? Qtrue : Qfalse; #else rb_notimplement(); #endif }
static VALUE curses_resizeterm(VALUE obj, VALUE lin, VALUE col) { #if defined(HAVE_RESIZETERM) curses_stdscr(); return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse; #else return Qnil; #endif }
static VALUE curses_resizeterm(VALUE obj, VALUE lin, VALUE col) { #if defined(HAVE_RESIZETERM) curses_stdscr(); return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse; #else return Qnil; #endif }
static VALUE curses_scrl(VALUE obj, VALUE n) { /* may have to raise exception on ERR */ #ifdef HAVE_SCRL curses_stdscr(); return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse; #else return Qfalse; #endif }
def setpos(y, x)
static VALUE curses_setpos(VALUE obj, VALUE y, VALUE x) { curses_stdscr(); move(NUM2INT(y), NUM2INT(x)); return Qnil; }
static VALUE curses_setscrreg(VALUE obj, VALUE top, VALUE bottom) { /* may have to raise exception on ERR */ #ifdef HAVE_SETSCRREG curses_stdscr(); return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse; #else return Qfalse; #endif }
def standend
static VALUE curses_standend(VALUE obj) { curses_stdscr(); standend(); return Qnil; }
def standout
static VALUE curses_standout(VALUE obj) { curses_stdscr(); standout(); return Qnil; }
static VALUE curses_start_color(VALUE obj) { /* may have to raise exception on ERR */ curses_stdscr(); return (start_color() == OK) ? Qtrue : Qfalse; }
USE_MOUSE
static VALUE curses_timeout(VALUE obj, VALUE delay) { #ifdef HAVE_TIMEOUT curses_stdscr(); timeout(NUM2INT(delay)); return Qnil; #else rb_notimplement(); #endif }