1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/curses/curses.c: made indentation consistent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-12-09 04:42:51 +00:00
parent 541915b239
commit 7f36764938

View file

@ -509,72 +509,72 @@ static VALUE
curses_curs_set(VALUE obj, VALUE visibility) curses_curs_set(VALUE obj, VALUE visibility)
{ {
#ifdef HAVE_CURS_SET #ifdef HAVE_CURS_SET
int n; int n;
return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil; return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil;
#else #else
return Qnil; return Qnil;
#endif #endif
} }
static VALUE static VALUE
curses_scrl(VALUE obj, VALUE n) curses_scrl(VALUE obj, VALUE n)
{ {
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
#ifdef HAVE_SCRL #ifdef HAVE_SCRL
return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse; return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse;
#else #else
return Qfalse; return Qfalse;
#endif #endif
} }
static VALUE static VALUE
curses_setscrreg(VALUE obj, VALUE top, VALUE bottom) curses_setscrreg(VALUE obj, VALUE top, VALUE bottom)
{ {
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
#ifdef HAVE_SETSCRREG #ifdef HAVE_SETSCRREG
return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse; return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse;
#else #else
return Qfalse; return Qfalse;
#endif #endif
} }
static VALUE static VALUE
curses_attroff(VALUE obj, VALUE attrs) curses_attroff(VALUE obj, VALUE attrs)
{ {
return window_attroff(rb_stdscr,attrs); return window_attroff(rb_stdscr,attrs);
/* return INT2FIX(attroff(NUM2INT(attrs))); */ /* return INT2FIX(attroff(NUM2INT(attrs))); */
} }
static VALUE static VALUE
curses_attron(VALUE obj, VALUE attrs) curses_attron(VALUE obj, VALUE attrs)
{ {
return window_attron(rb_stdscr,attrs); return window_attron(rb_stdscr,attrs);
/* return INT2FIX(attroff(NUM2INT(attrs))); */ /* return INT2FIX(attroff(NUM2INT(attrs))); */
} }
static VALUE static VALUE
curses_attrset(VALUE obj, VALUE attrs) curses_attrset(VALUE obj, VALUE attrs)
{ {
return window_attrset(rb_stdscr,attrs); return window_attrset(rb_stdscr,attrs);
/* return INT2FIX(attroff(NUM2INT(attrs))); */ /* return INT2FIX(attroff(NUM2INT(attrs))); */
} }
static VALUE static VALUE
curses_bkgdset(VALUE obj, VALUE ch) curses_bkgdset(VALUE obj, VALUE ch)
{ {
#ifdef HAVE_BKGDSET #ifdef HAVE_BKGDSET
bkgdset(NUM2CH(ch)); bkgdset(NUM2CH(ch));
#endif #endif
return Qnil; return Qnil;
} }
static VALUE static VALUE
curses_bkgd(VALUE obj, VALUE ch) curses_bkgd(VALUE obj, VALUE ch)
{ {
#ifdef HAVE_BKGD #ifdef HAVE_BKGD
return (bkgd(NUM2CH(ch)) == OK) ? Qtrue : Qfalse; return (bkgd(NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
#else #else
return Qfalse; return Qfalse;
#endif #endif
} }
@ -582,10 +582,10 @@ static VALUE
curses_use_default_colors(VALUE obj) curses_use_default_colors(VALUE obj)
{ {
#if defined(HAVE_USE_DEFAULT_COLORS) #if defined(HAVE_USE_DEFAULT_COLORS)
use_default_colors(); use_default_colors();
return Qnil; return Qnil;
#else #else
rb_notimplement(); rb_notimplement();
#endif #endif
} }
@ -593,10 +593,10 @@ static VALUE
curses_tabsize_set(VALUE obj, VALUE val) curses_tabsize_set(VALUE obj, VALUE val)
{ {
#if defined(HAVE_TABSIZE) #if defined(HAVE_TABSIZE)
TABSIZE=NUM2INT(val); TABSIZE = NUM2INT(val);
return INT2NUM(TABSIZE); return INT2NUM(TABSIZE);
#else #else
rb_notimplement(); rb_notimplement();
#endif #endif
} }
@ -604,9 +604,9 @@ static VALUE
curses_tabsize_get(VALUE ojb) curses_tabsize_get(VALUE ojb)
{ {
#if defined(HAVE_TABSIZE) #if defined(HAVE_TABSIZE)
return INT2NUM(TABSIZE); return INT2NUM(TABSIZE);
#else #else
rb_notimplement(); rb_notimplement();
#endif #endif
} }
@ -614,10 +614,10 @@ static VALUE
curses_escdelay_set(VALUE obj, VALUE val) curses_escdelay_set(VALUE obj, VALUE val)
{ {
#if defined(HAVE_ESCDELAY) #if defined(HAVE_ESCDELAY)
ESCDELAY=NUM2INT(val); ESCDELAY = NUM2INT(val);
return INT2NUM(ESCDELAY); return INT2NUM(ESCDELAY);
#else #else
rb_notimplement(); rb_notimplement();
#endif #endif
} }
@ -625,9 +625,9 @@ static VALUE
curses_escdelay_get(VALUE obj) curses_escdelay_get(VALUE obj)
{ {
#if defined(HAVE_ESCDELAY) #if defined(HAVE_ESCDELAY)
return INT2NUM(ESCDELAY); return INT2NUM(ESCDELAY);
#else #else
rb_notimplement(); rb_notimplement();
#endif #endif
} }
@ -635,9 +635,9 @@ static VALUE
curses_resizeterm(VALUE obj, VALUE lin, VALUE col) curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
{ {
#if defined(HAVE_RESIZETERM) #if defined(HAVE_RESIZETERM)
return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse; return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse;
#else #else
return Qnil; return Qnil;
#endif #endif
} }
@ -645,77 +645,77 @@ curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
static VALUE static VALUE
curses_start_color(VALUE obj) curses_start_color(VALUE obj)
{ {
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
return (start_color() == OK) ? Qtrue : Qfalse; return (start_color() == OK) ? Qtrue : Qfalse;
} }
static VALUE static VALUE
curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b) curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b)
{ {
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse; return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
} }
static VALUE static VALUE
curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b) curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b)
{ {
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
return (init_color(NUM2INT(color),NUM2INT(r), return (init_color(NUM2INT(color),NUM2INT(r),
NUM2INT(g),NUM2INT(b)) == OK) ? Qtrue : Qfalse; NUM2INT(g),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
} }
static VALUE static VALUE
curses_has_colors(VALUE obj) curses_has_colors(VALUE obj)
{ {
return has_colors() ? Qtrue : Qfalse; return has_colors() ? Qtrue : Qfalse;
} }
static VALUE static VALUE
curses_can_change_color(VALUE obj) curses_can_change_color(VALUE obj)
{ {
return can_change_color() ? Qtrue : Qfalse; return can_change_color() ? Qtrue : Qfalse;
} }
static VALUE static VALUE
curses_color_content(VALUE obj, VALUE color) curses_color_content(VALUE obj, VALUE color)
{ {
short r,g,b; short r,g,b;
color_content(NUM2INT(color),&r,&g,&b); color_content(NUM2INT(color),&r,&g,&b);
return rb_ary_new3(3,INT2FIX(r),INT2FIX(g),INT2FIX(b)); return rb_ary_new3(3,INT2FIX(r),INT2FIX(g),INT2FIX(b));
} }
static VALUE static VALUE
curses_pair_content(VALUE obj, VALUE pair) curses_pair_content(VALUE obj, VALUE pair)
{ {
short f,b; short f,b;
pair_content(NUM2INT(pair),&f,&b); pair_content(NUM2INT(pair),&f,&b);
return rb_ary_new3(2,INT2FIX(f),INT2FIX(b)); return rb_ary_new3(2,INT2FIX(f),INT2FIX(b));
} }
static VALUE static VALUE
curses_color_pair(VALUE obj, VALUE attrs) curses_color_pair(VALUE obj, VALUE attrs)
{ {
return INT2FIX(COLOR_PAIR(NUM2INT(attrs))); return INT2FIX(COLOR_PAIR(NUM2INT(attrs)));
} }
static VALUE static VALUE
curses_pair_number(VALUE obj, VALUE attrs) curses_pair_number(VALUE obj, VALUE attrs)
{ {
return INT2FIX(PAIR_NUMBER(NUM2INT(attrs))); return INT2FIX(PAIR_NUMBER(NUM2INT(attrs)));
} }
#endif /* USE_COLOR */ #endif /* USE_COLOR */
#ifdef USE_MOUSE #ifdef USE_MOUSE
struct mousedata { struct mousedata {
MEVENT *mevent; MEVENT *mevent;
}; };
static void static void
no_mevent(void) no_mevent(void)
{ {
rb_raise(rb_eRuntimeError, "no such mouse event"); rb_raise(rb_eRuntimeError, "no such mouse event");
} }
#define GetMOUSE(obj, data) do {\ #define GetMOUSE(obj, data) do {\
@ -728,49 +728,49 @@ no_mevent(void)
static void static void
curses_mousedata_free(struct mousedata *mdata) curses_mousedata_free(struct mousedata *mdata)
{ {
if (mdata->mevent) if (mdata->mevent)
xfree(mdata->mevent); xfree(mdata->mevent);
} }
static VALUE static VALUE
curses_getmouse(VALUE obj) curses_getmouse(VALUE obj)
{ {
struct mousedata *mdata; struct mousedata *mdata;
VALUE val; VALUE val;
val = Data_Make_Struct(cMouseEvent,struct mousedata, val = Data_Make_Struct(cMouseEvent,struct mousedata,
0,curses_mousedata_free,mdata); 0,curses_mousedata_free,mdata);
mdata->mevent = (MEVENT*)xmalloc(sizeof(MEVENT)); mdata->mevent = (MEVENT*)xmalloc(sizeof(MEVENT));
return (getmouse(mdata->mevent) == OK) ? val : Qnil; return (getmouse(mdata->mevent) == OK) ? val : Qnil;
} }
static VALUE static VALUE
curses_ungetmouse(VALUE obj, VALUE mevent) curses_ungetmouse(VALUE obj, VALUE mevent)
{ {
struct mousedata *mdata; struct mousedata *mdata;
GetMOUSE(mevent,mdata); GetMOUSE(mevent,mdata);
return (ungetmouse(mdata->mevent) == OK) ? Qtrue : Qfalse; return (ungetmouse(mdata->mevent) == OK) ? Qtrue : Qfalse;
} }
static VALUE static VALUE
curses_mouseinterval(VALUE obj, VALUE interval) curses_mouseinterval(VALUE obj, VALUE interval)
{ {
return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse; return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse;
} }
static VALUE static VALUE
curses_mousemask(VALUE obj, VALUE mask) curses_mousemask(VALUE obj, VALUE mask)
{ {
return INT2NUM(mousemask(NUM2UINT(mask),NULL)); return INT2NUM(mousemask(NUM2UINT(mask),NULL));
} }
#define DEFINE_MOUSE_GET_MEMBER(func_name,mem) \ #define DEFINE_MOUSE_GET_MEMBER(func_name,mem) \
static VALUE func_name (VALUE mouse) \ static VALUE func_name (VALUE mouse) \
{ \ { \
struct mousedata *mdata; \ struct mousedata *mdata; \
GetMOUSE(mouse, mdata); \ GetMOUSE(mouse, mdata); \
return (UINT2NUM(mdata->mevent -> mem)); \ return (UINT2NUM(mdata->mevent -> mem)); \
} }
DEFINE_MOUSE_GET_MEMBER(curs_mouse_id, id) DEFINE_MOUSE_GET_MEMBER(curs_mouse_id, id)
@ -785,8 +785,8 @@ static VALUE
curses_timeout(VALUE obj, VALUE delay) curses_timeout(VALUE obj, VALUE delay)
{ {
#ifdef HAVE_TIMEOUT #ifdef HAVE_TIMEOUT
timeout(NUM2INT(delay)); timeout(NUM2INT(delay));
return Qnil; return Qnil;
#else #else
rb_notimplement(); rb_notimplement();
#endif #endif
@ -796,7 +796,7 @@ static VALUE
curses_def_prog_mode(VALUE obj) curses_def_prog_mode(VALUE obj)
{ {
#ifdef HAVE_DEF_PROG_MODE #ifdef HAVE_DEF_PROG_MODE
return def_prog_mode() == OK ? Qtrue : Qfalse; return def_prog_mode() == OK ? Qtrue : Qfalse;
#else #else
rb_notimplement(); rb_notimplement();
#endif #endif
@ -806,7 +806,7 @@ static VALUE
curses_reset_prog_mode(VALUE obj) curses_reset_prog_mode(VALUE obj)
{ {
#ifdef HAVE_RESET_PROG_MODE #ifdef HAVE_RESET_PROG_MODE
return reset_prog_mode() == OK ? Qtrue : Qfalse; return reset_prog_mode() == OK ? Qtrue : Qfalse;
#else #else
rb_notimplement(); rb_notimplement();
#endif #endif
@ -1058,22 +1058,22 @@ window_box(int argc, VALUE *argv, VALUE self)
box(winp->window, NUM2CH(vert), NUM2CH(hor)); box(winp->window, NUM2CH(vert), NUM2CH(hor));
if (!NIL_P(corn)) { if (!NIL_P(corn)) {
int cur_x, cur_y, x, y; int cur_x, cur_y, x, y;
chtype c; chtype c;
c = NUM2CH(corn); c = NUM2CH(corn);
getyx(winp->window, cur_y, cur_x); getyx(winp->window, cur_y, cur_x);
x = NUM2INT(window_maxx(self)) - 1; x = NUM2INT(window_maxx(self)) - 1;
y = NUM2INT(window_maxy(self)) - 1; y = NUM2INT(window_maxy(self)) - 1;
wmove(winp->window, 0, 0); wmove(winp->window, 0, 0);
waddch(winp->window, c); waddch(winp->window, c);
wmove(winp->window, y, 0); wmove(winp->window, y, 0);
waddch(winp->window, c); waddch(winp->window, c);
wmove(winp->window, y, x); wmove(winp->window, y, x);
waddch(winp->window, c); waddch(winp->window, c);
wmove(winp->window, 0, x); wmove(winp->window, 0, x);
waddch(winp->window, c); waddch(winp->window, c);
wmove(winp->window, cur_y, cur_x); wmove(winp->window, cur_y, cur_x);
} }
return Qnil; return Qnil;
@ -1234,36 +1234,36 @@ window_insertln(VALUE obj)
static VALUE static VALUE
window_scrollok(VALUE obj, VALUE bf) window_scrollok(VALUE obj, VALUE bf)
{ {
struct windata *winp; struct windata *winp;
GetWINDOW(obj, winp); GetWINDOW(obj, winp);
scrollok(winp->window, RTEST(bf) ? TRUE : FALSE); scrollok(winp->window, RTEST(bf) ? TRUE : FALSE);
return Qnil; return Qnil;
} }
static VALUE static VALUE
window_idlok(VALUE obj, VALUE bf) window_idlok(VALUE obj, VALUE bf)
{ {
struct windata *winp; struct windata *winp;
GetWINDOW(obj, winp); GetWINDOW(obj, winp);
idlok(winp->window, RTEST(bf) ? TRUE : FALSE); idlok(winp->window, RTEST(bf) ? TRUE : FALSE);
return Qnil; return Qnil;
} }
static VALUE static VALUE
window_setscrreg(VALUE obj, VALUE top, VALUE bottom) window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
{ {
#ifdef HAVE_WSETSCRREG #ifdef HAVE_WSETSCRREG
struct windata *winp; struct windata *winp;
int res; int res;
GetWINDOW(obj, winp); GetWINDOW(obj, winp);
res = wsetscrreg(winp->window, NUM2INT(top), NUM2INT(bottom)); res = wsetscrreg(winp->window, NUM2INT(top), NUM2INT(bottom));
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
return (res == OK) ? Qtrue : Qfalse; return (res == OK) ? Qtrue : Qfalse;
#else #else
return Qfalse; return Qfalse;
#endif #endif
} }
@ -1271,36 +1271,36 @@ window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
static VALUE static VALUE
window_color_set(VALUE obj, VALUE col) window_color_set(VALUE obj, VALUE col)
{ {
struct windata *winp; struct windata *winp;
int res; int res;
GetWINDOW(obj, winp); GetWINDOW(obj, winp);
res = wcolor_set(winp->window, NUM2INT(col), NULL); res = wcolor_set(winp->window, NUM2INT(col), NULL);
return (res == OK) ? Qtrue : Qfalse; return (res == OK) ? Qtrue : Qfalse;
} }
#endif /* defined(USE_COLOR) && defined(HAVE_WCOLOR_SET) */ #endif /* defined(USE_COLOR) && defined(HAVE_WCOLOR_SET) */
static VALUE static VALUE
window_scroll(VALUE obj) window_scroll(VALUE obj)
{ {
struct windata *winp; struct windata *winp;
GetWINDOW(obj, winp); GetWINDOW(obj, winp);
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
return (scroll(winp->window) == OK) ? Qtrue : Qfalse; return (scroll(winp->window) == OK) ? Qtrue : Qfalse;
} }
static VALUE static VALUE
window_scrl(VALUE obj, VALUE n) window_scrl(VALUE obj, VALUE n)
{ {
#ifdef HAVE_WSCRL #ifdef HAVE_WSCRL
struct windata *winp; struct windata *winp;
GetWINDOW(obj, winp); GetWINDOW(obj, winp);
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
return (wscrl(winp->window,NUM2INT(n)) == OK) ? Qtrue : Qfalse; return (wscrl(winp->window,NUM2INT(n)) == OK) ? Qtrue : Qfalse;
#else #else
return Qfalse; return Qfalse;
#endif #endif
} }
@ -1308,12 +1308,12 @@ static VALUE
window_attroff(VALUE obj, VALUE attrs) window_attroff(VALUE obj, VALUE attrs)
{ {
#ifdef HAVE_WATTROFF #ifdef HAVE_WATTROFF
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
return INT2FIX(wattroff(winp->window,NUM2INT(attrs))); return INT2FIX(wattroff(winp->window,NUM2INT(attrs)));
#else #else
return Qtrue; return Qtrue;
#endif #endif
} }
@ -1321,21 +1321,21 @@ static VALUE
window_attron(VALUE obj, VALUE attrs) window_attron(VALUE obj, VALUE attrs)
{ {
#ifdef HAVE_WATTRON #ifdef HAVE_WATTRON
struct windata *winp; struct windata *winp;
VALUE val; VALUE val;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
val = INT2FIX(wattron(winp->window,NUM2INT(attrs))); val = INT2FIX(wattron(winp->window,NUM2INT(attrs)));
if( rb_block_given_p() ){ if( rb_block_given_p() ){
rb_yield(val); rb_yield(val);
wattroff(winp->window,NUM2INT(attrs)); wattroff(winp->window,NUM2INT(attrs));
return val; return val;
} }
else{ else{
return val; return val;
} }
#else #else
return Qtrue; return Qtrue;
#endif #endif
} }
@ -1343,12 +1343,12 @@ static VALUE
window_attrset(VALUE obj, VALUE attrs) window_attrset(VALUE obj, VALUE attrs)
{ {
#ifdef HAVE_WATTRSET #ifdef HAVE_WATTRSET
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
return INT2FIX(wattrset(winp->window,NUM2INT(attrs))); return INT2FIX(wattrset(winp->window,NUM2INT(attrs)));
#else #else
return Qtrue; return Qtrue;
#endif #endif
} }
@ -1356,24 +1356,24 @@ static VALUE
window_bkgdset(VALUE obj, VALUE ch) window_bkgdset(VALUE obj, VALUE ch)
{ {
#ifdef HAVE_WBKGDSET #ifdef HAVE_WBKGDSET
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
wbkgdset(winp->window, NUM2CH(ch)); wbkgdset(winp->window, NUM2CH(ch));
#endif #endif
return Qnil; return Qnil;
} }
static VALUE static VALUE
window_bkgd(VALUE obj, VALUE ch) window_bkgd(VALUE obj, VALUE ch)
{ {
#ifdef HAVE_WBKGD #ifdef HAVE_WBKGD
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
return (wbkgd(winp->window, NUM2CH(ch)) == OK) ? Qtrue : Qfalse; return (wbkgd(winp->window, NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
#else #else
return Qfalse; return Qfalse;
#endif #endif
} }
@ -1381,13 +1381,13 @@ static VALUE
window_getbkgd(VALUE obj) window_getbkgd(VALUE obj)
{ {
#ifdef HAVE_WGETBKGD #ifdef HAVE_WGETBKGD
chtype c; chtype c;
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
return (c = getbkgd(winp->window) != ERR) ? CH2FIX(c) : Qnil; return (c = getbkgd(winp->window) != ERR) ? CH2FIX(c) : Qnil;
#else #else
return Qnil; return Qnil;
#endif #endif
} }
@ -1395,12 +1395,12 @@ static VALUE
window_resize(VALUE obj, VALUE lin, VALUE col) window_resize(VALUE obj, VALUE lin, VALUE col)
{ {
#if defined(HAVE_WRESIZE) #if defined(HAVE_WRESIZE)
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
return wresize(winp->window, NUM2INT(lin), NUM2INT(col)) == OK ? Qtrue : Qfalse; return wresize(winp->window, NUM2INT(lin), NUM2INT(col)) == OK ? Qtrue : Qfalse;
#else #else
return Qnil; return Qnil;
#endif #endif
} }
@ -1409,17 +1409,17 @@ static VALUE
window_keypad(VALUE obj, VALUE val) window_keypad(VALUE obj, VALUE val)
{ {
#ifdef HAVE_KEYPAD #ifdef HAVE_KEYPAD
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
/* keypad() of NetBSD's libcurses returns no value */ /* keypad() of NetBSD's libcurses returns no value */
#if defined(__NetBSD__) && !defined(NCURSES_VERSION) #if defined(__NetBSD__) && !defined(NCURSES_VERSION)
keypad(winp->window,(RTEST(val) ? TRUE : FALSE)); keypad(winp->window,(RTEST(val) ? TRUE : FALSE));
return Qnil; return Qnil;
#else #else
/* may have to raise exception on ERR */ /* may have to raise exception on ERR */
return (keypad(winp->window,RTEST(val) ? TRUE : FALSE)) == OK ? return (keypad(winp->window,RTEST(val) ? TRUE : FALSE)) == OK ?
Qtrue : Qfalse; Qtrue : Qfalse;
#endif #endif
#else #else
rb_notimplement(); rb_notimplement();
@ -1430,15 +1430,15 @@ static VALUE
window_nodelay(VALUE obj, VALUE val) window_nodelay(VALUE obj, VALUE val)
{ {
#ifdef HAVE_NODELAY #ifdef HAVE_NODELAY
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
/* nodelay() of NetBSD's libcurses returns no value */ /* nodelay() of NetBSD's libcurses returns no value */
#if defined(__NetBSD__) && !defined(NCURSES_VERSION) #if defined(__NetBSD__) && !defined(NCURSES_VERSION)
nodelay(winp->window, RTEST(val) ? TRUE : FALSE); nodelay(winp->window, RTEST(val) ? TRUE : FALSE);
return Qnil; return Qnil;
#else #else
return nodelay(winp->window,RTEST(val) ? TRUE : FALSE) == OK ? Qtrue : Qfalse; return nodelay(winp->window,RTEST(val) ? TRUE : FALSE) == OK ? Qtrue : Qfalse;
#endif #endif
#else #else
rb_notimplement(); rb_notimplement();
@ -1449,11 +1449,11 @@ static VALUE
window_timeout(VALUE obj, VALUE delay) window_timeout(VALUE obj, VALUE delay)
{ {
#ifdef HAVE_WTIMEOUT #ifdef HAVE_WTIMEOUT
struct windata *winp; struct windata *winp;
GetWINDOW(obj,winp); GetWINDOW(obj,winp);
wtimeout(winp->window,NUM2INT(delay)); wtimeout(winp->window,NUM2INT(delay));
return Qnil; return Qnil;
#else #else
rb_notimplement(); rb_notimplement();
#endif #endif
@ -1773,14 +1773,14 @@ Init_curses(void)
#ifdef KEY_F #ifdef KEY_F
/* KEY_F(n) : 0 <= n <= 63 */ /* KEY_F(n) : 0 <= n <= 63 */
{ {
int i; int i;
char c[8]; char c[8];
for( i=0; i<64; i++ ){ for( i=0; i<64; i++ ){
sprintf(c, "KEY_F%d", i); sprintf(c, "KEY_F%d", i);
rb_define_const(mCurses, c, INT2NUM(KEY_F(i))); rb_define_const(mCurses, c, INT2NUM(KEY_F(i)));
sprintf(c, "F%d", i); sprintf(c, "F%d", i);
rb_define_const(mKey, c, INT2NUM(KEY_F(i))); rb_define_const(mKey, c, INT2NUM(KEY_F(i)));
} }
} }
#endif #endif
#ifdef KEY_DL #ifdef KEY_DL
@ -2116,12 +2116,12 @@ Init_curses(void)
rb_define_const(mKey, "MAX", INT2NUM(KEY_MAX)); rb_define_const(mKey, "MAX", INT2NUM(KEY_MAX));
#endif #endif
{ {
int c; int c;
char name[] = "KEY_CTRL_x"; char name[] = "KEY_CTRL_x";
for( c = 'A'; c <= 'Z'; c++ ){ for( c = 'A'; c <= 'Z'; c++ ){
sprintf(name, "KEY_CTRL_%c", c); sprintf(name, "KEY_CTRL_%c", c);
rb_define_const(mCurses, name, INT2FIX(c - 'A' + 1)); rb_define_const(mCurses, name, INT2FIX(c - 'A' + 1));
} }
} }
#undef rb_curses_define_const #undef rb_curses_define_const