————————- Initialization ————————-
def addch(ch)
static VALUE curses_addch(obj, ch) VALUE obj; VALUE ch; { curses_stdscr(); addch(NUM2CH(ch)); return Qnil; }
def addstr(str)
static VALUE curses_addstr(obj, str) VALUE obj; VALUE str; { curses_stdscr(); if (!NIL_P(str)) { addstr(STR2CSTR(str)); } return Qnil; }
static VALUE curses_attroff(VALUE obj, VALUE attrs) { return window_attroff(rb_stdscr,attrs); /* return INT2FIX(attroff(NUM2INT(attrs))); */ }
static VALUE curses_attron(VALUE obj, VALUE attrs) { return window_attron(rb_stdscr,attrs); /* return INT2FIX(attroff(NUM2INT(attrs))); */ }
static VALUE curses_attrset(VALUE obj, VALUE attrs) { return window_attrset(rb_stdscr,attrs); /* return INT2FIX(attroff(NUM2INT(attrs))); */ }
def beep
static VALUE curses_beep(obj) VALUE obj; { #ifdef HAVE_BEEP curses_stdscr(); beep(); #endif return Qnil; }
static VALUE curses_bkgd(VALUE obj, VALUE ch) { #ifdef HAVE_BKGD return (bkgd(NUM2CH(ch)) == OK) ? Qtrue : Qfalse; #else return Qfalse; #endif }
static VALUE curses_bkgdset(VALUE obj, VALUE ch) { #ifdef HAVE_BKGDSET bkgdset(NUM2CH(ch)); #endif return Qnil; }
static VALUE curses_can_change_color(VALUE obj) { return can_change_color() ? Qtrue : Qfalse; }
def cbreak
static VALUE curses_cbreak(obj) VALUE obj; { curses_stdscr(); cbreak(); return Qnil; }
def clear
static VALUE curses_clear(obj) VALUE obj; { curses_stdscr(); wclear(stdscr); return Qnil; }
def ::close_screen
static VALUE curses_close_screen() { #ifdef HAVE_ISENDWIN if (!isendwin()) #endif endwin(); rb_stdscr = 0; return Qnil; }
def closed?
static VALUE curses_closed() { #ifdef HAVE_ISENDWIN if (isendwin()) { return Qtrue; } return Qfalse; #else rb_notimplement(); #endif }
def clrtoeol
static VALUE curses_clrtoeol() { curses_stdscr(); clrtoeol(); return Qnil; }
static VALUE curses_color_content(VALUE obj, VALUE color) { short r,g,b; 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; 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 return def_prog_mode() == OK ? Qtrue : Qfalse; #else rb_notimplement(); #endif }
def delch
static VALUE curses_delch(obj) VALUE obj; { delch(); return Qnil; }
def delelteln
static VALUE curses_deleteln(obj) VALUE obj; { #if defined(HAVE_DELETELN) || defined(deleteln) deleteln(); #endif return Qnil; }
def doupdate
static VALUE curses_doupdate(obj) VALUE obj; { curses_stdscr(); #ifdef HAVE_DOUPDATE doupdate(); #else refresh(); #endif return Qnil; }
def echo
static VALUE curses_echo(obj) VALUE obj; { curses_stdscr(); echo(); return Qnil; }
def flash
static VALUE curses_flash(obj) VALUE obj; { #ifdef HAVE_FLASH curses_stdscr(); flash(); #endif return Qnil; }
def getch
static VALUE curses_getch(obj) VALUE obj; { rb_read_check(stdin); curses_stdscr(); return UINT2NUM(getch()); }
static VALUE curses_getmouse(VALUE obj) { struct mousedata *mdata; VALUE val; 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(obj) VALUE obj; { char rtn[1024]; /* This should be big enough.. I hope */ rb_read_check(stdin); #if defined(HAVE_GETNSTR) getnstr(rtn,1023); #else getstr(rtn); #endif return rb_tainted_str_new2(rtn); }
static VALUE curses_has_colors(VALUE obj) { return has_colors() ? Qtrue : Qfalse; }
def inch
static VALUE curses_inch(obj) 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 */ 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 */ return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse; }
def ::init_screen
static VALUE curses_init_screen() { 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(obj, ch) VALUE obj; VALUE ch; { curses_stdscr(); insch(NUM2CH(ch)); return Qnil; }
def insertln
static VALUE curses_insertln(obj) VALUE obj; { #if defined(HAVE_INSERTLN) || defined(insertln) insertln(); #endif return Qnil; }
def keyname
static VALUE curses_keyname(obj, c) VALUE obj; VALUE c; { #ifdef HAVE_KEYNAME const char *name; name = keyname(NUM2INT(c)); if (name) { return rb_str_new2(name); } else { return Qnil; } #else return Qnil; #endif }
static VALUE curses_mouseinterval(VALUE obj, VALUE interval) { return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse; }
static VALUE curses_mousemask(VALUE obj, VALUE mask) { return INT2NUM(mousemask(NUM2UINT(mask),NULL)); }
def nl
static VALUE curses_nl(obj) VALUE obj; { curses_stdscr(); nl(); return Qnil; }
def nocbreak
static VALUE curses_nocbreak(obj) VALUE obj; { curses_stdscr(); nocbreak(); return Qnil; }
def noecho
static VALUE curses_noecho(obj) VALUE obj; { curses_stdscr(); noecho(); return Qnil; }
def nonl
static VALUE curses_nonl(obj) VALUE obj; { curses_stdscr(); nonl(); return Qnil; }
def noraw
static VALUE curses_noraw(obj) VALUE obj; { curses_stdscr(); noraw(); return Qnil; }
static VALUE curses_pair_content(VALUE obj, VALUE pair) { short f,b; pair_content(NUM2INT(pair),&f,&b); return rb_ary_new3(2,INT2FIX(f),INT2FIX(b)); }
static VALUE curses_pair_number(VALUE obj, VALUE attrs) { return INT2FIX(PAIR_NUMBER(NUM2INT(attrs))); }
def raw
static VALUE curses_raw(obj) VALUE obj; { curses_stdscr(); raw(); return Qnil; }
def refresh
static VALUE curses_refresh(obj) VALUE obj; { curses_stdscr(); refresh(); return Qnil; }
static VALUE curses_reset_prog_mode(VALUE obj) { #ifdef HAVE_RESET_PROG_MODE 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) 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) 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 return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse; #else return Qfalse; #endif }
def setpos(y, x)
static VALUE curses_setpos(obj, y, x) 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 return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse; #else return Qfalse; #endif }
def standend
static VALUE curses_standend(obj) VALUE obj; { standend(); return Qnil; }
def standout
static VALUE curses_standout(obj) VALUE obj; { standout(); return Qnil; }
static VALUE curses_start_color(VALUE obj) { /* may have to raise exception on ERR */ return (start_color() == OK) ? Qtrue : Qfalse; }
USE_MOUSE
static VALUE curses_timeout(VALUE obj, VALUE delay) { #ifdef HAVE_TIMEOUT timeout(NUM2INT(delay)); return Qnil; #else rb_notimplement(); #endif }