@@ -302,7 +302,7 @@ static void curses_finalize(VALUE);
302302 * see also Curses.stdscr
303303 */
304304static VALUE
305- curses_init_screen (void )
305+ curses_init_screen (VALUE self )
306306{
307307 if (rb_stdscr ) return rb_stdscr ;
308308 initscr ();
@@ -325,7 +325,7 @@ curses_init_screen(void)
325325 *
326326 * Many curses functions use this window.
327327 */
328- #define curses_stdscr curses_init_screen
328+ #define curses_stdscr () curses_init_screen(Qnil)
329329
330330/*
331331 * Document-method: Curses.close_screen
@@ -341,7 +341,7 @@ curses_init_screen(void)
341341 *
342342 */
343343static VALUE
344- curses_close_screen (void )
344+ curses_close_screen (VALUE self )
345345{
346346 curses_stdscr ();
347347#ifdef HAVE_ISENDWIN
@@ -381,7 +381,7 @@ curses_finalize(VALUE dummy)
381381 * returns +false+ otherwise.
382382 */
383383static VALUE
384- curses_closed (void )
384+ curses_closed (VALUE self )
385385{
386386 curses_stdscr ();
387387 if (isendwin ()) {
@@ -431,7 +431,7 @@ curses_erase(VALUE obj)
431431 * Clears to the end of line, that the cursor is currently on.
432432 */
433433static VALUE
434- curses_clrtoeol (void )
434+ curses_clrtoeol (VALUE self )
435435{
436436 curses_stdscr ();
437437 clrtoeol ();
@@ -960,7 +960,7 @@ curses_keyname(VALUE obj, VALUE c)
960960 * Returns the number of lines on the screen
961961 */
962962static VALUE
963- curses_lines (void )
963+ curses_lines (VALUE self )
964964{
965965 return INT2FIX (LINES );
966966}
@@ -971,7 +971,7 @@ curses_lines(void)
971971 * Returns the number of columns on the screen
972972 */
973973static VALUE
974- curses_cols (void )
974+ curses_cols (VALUE self )
975975{
976976 return INT2FIX (COLS );
977977}
@@ -1559,7 +1559,7 @@ static VALUE
15591559curses_mousemask (VALUE obj , VALUE mask )
15601560{
15611561 curses_stdscr ();
1562- return INT2NUM (mousemask (NUM2UINT (mask ),NULL ));
1562+ return ULONG2NUM (mousemask (NUM2UINT (mask ),NULL ));
15631563}
15641564
15651565#define DEFINE_MOUSE_GET_MEMBER (func_name ,mem ) \
@@ -1600,7 +1600,12 @@ DEFINE_MOUSE_GET_MEMBER(curs_mouse_z, z)
16001600 * Returns the current mouse's button state. Use this with the button state
16011601 * constants to determine which buttons were pressed.
16021602 */
1603- DEFINE_MOUSE_GET_MEMBER (curs_mouse_bstate , bstate )
1603+ static VALUE curs_mouse_bstate (VALUE mouse )
1604+ {
1605+ struct mousedata * mdata ;
1606+ GetMOUSE (mouse , mdata );
1607+ return ULONG2NUM (mdata -> mevent -> bstate );
1608+ }
16041609#undef define_curs_mouse_member
16051610#endif /* USE_MOUSE */
16061611
@@ -1692,7 +1697,7 @@ window_initialize(VALUE obj, VALUE h, VALUE w, VALUE top, VALUE left)
16921697 struct windata * winp ;
16931698 WINDOW * window ;
16941699
1695- curses_init_screen ();
1700+ curses_init_screen (Qnil );
16961701 TypedData_Get_Struct (obj , struct windata , & windata_type , winp );
16971702 if (winp -> window ) delwin (winp -> window );
16981703 window = newwin (NUM2INT (h ), NUM2INT (w ), NUM2INT (top ), NUM2INT (left ));
@@ -2932,7 +2937,7 @@ pad_initialize(VALUE obj, VALUE h, VALUE w)
29322937 struct windata * padp ;
29332938 WINDOW * window ;
29342939
2935- curses_init_screen ();
2940+ curses_init_screen (Qnil );
29362941 TypedData_Get_Struct (obj , struct windata , & windata_type , padp );
29372942 if (padp -> window ) delwin (padp -> window );
29382943 window = newpad (NUM2INT (h ), NUM2INT (w ));
@@ -3103,7 +3108,7 @@ item_initialize(VALUE obj, VALUE name, VALUE description)
31033108{
31043109 struct itemdata * itemp ;
31053110
3106- curses_init_screen ();
3111+ curses_init_screen (Qnil );
31073112 TypedData_Get_Struct (obj , struct itemdata , & itemdata_type , itemp );
31083113 if (itemp -> item ) {
31093114 rb_raise (rb_eRuntimeError , "already initialized item" );
@@ -3316,7 +3321,7 @@ menu_initialize(VALUE obj, VALUE items)
33163321 ID id_new ;
33173322
33183323 Check_Type (items , T_ARRAY );
3319- curses_init_screen ();
3324+ curses_init_screen (Qnil );
33203325 TypedData_Get_Struct (obj , struct menudata , & menudata_type , menup );
33213326 if (menup -> menu ) {
33223327 rb_raise (rb_eRuntimeError , "already initialized menu" );
@@ -3772,7 +3777,7 @@ field_initialize(VALUE obj, VALUE height, VALUE width,
37723777{
37733778 struct fielddata * fieldp ;
37743779
3775- curses_init_screen ();
3780+ curses_init_screen (Qnil );
37763781 TypedData_Get_Struct (obj , struct fielddata , & fielddata_type , fieldp );
37773782 if (fieldp -> field ) {
37783783 rb_raise (rb_eRuntimeError , "already initialized field" );
@@ -4230,7 +4235,7 @@ form_initialize(VALUE obj, VALUE fields)
42304235 int i ;
42314236
42324237 Check_Type (fields , T_ARRAY );
4233- curses_init_screen ();
4238+ curses_init_screen (Qnil );
42344239 TypedData_Get_Struct (obj , struct formdata , & formdata_type , formp );
42354240 if (formp -> form ) {
42364241 rb_raise (rb_eRuntimeError , "already initialized form" );
@@ -4730,7 +4735,7 @@ Init_curses(void)
47304735 rb_define_module_function (mCurses , "init_screen" , curses_init_screen , 0 );
47314736 rb_define_module_function (mCurses , "close_screen" , curses_close_screen , 0 );
47324737 rb_define_module_function (mCurses , "closed?" , curses_closed , 0 );
4733- rb_define_module_function (mCurses , "stdscr" , curses_stdscr , 0 );
4738+ rb_define_module_function (mCurses , "stdscr" , curses_init_screen , 0 );
47344739 rb_define_module_function (mCurses , "refresh" , curses_refresh , 0 );
47354740 rb_define_module_function (mCurses , "doupdate" , curses_doupdate , 0 );
47364741 rb_define_module_function (mCurses , "clear" , curses_clear , 0 );
@@ -4870,7 +4875,7 @@ Init_curses(void)
48704875 * win.close
48714876 *
48724877 */
4873- cWindow = rb_define_class_under (mCurses , "Window" , rb_cData );
4878+ cWindow = rb_define_class_under (mCurses , "Window" , rb_cObject );
48744879 rb_define_alloc_func (cWindow , window_s_allocate );
48754880 rb_define_method (cWindow , "initialize" , window_initialize , 4 );
48764881 rb_define_method (cWindow , "subwin" , window_subwin , 4 );
@@ -4954,7 +4959,7 @@ Init_curses(void)
49544959#endif
49554960
49564961#ifdef HAVE_MENU
4957- cItem = rb_define_class_under (mCurses , "Item" , rb_cData );
4962+ cItem = rb_define_class_under (mCurses , "Item" , rb_cObject );
49584963 rb_define_alloc_func (cItem , item_s_allocate );
49594964 rb_define_method (cItem , "initialize" , item_initialize , 2 );
49604965 rb_define_method (cItem , "==" , item_eq , 1 );
@@ -4965,7 +4970,7 @@ Init_curses(void)
49654970 rb_define_method (cItem , "opts_off" , item_opts_off_m , 1 );
49664971 rb_define_method (cItem , "opts" , item_opts_m , 0 );
49674972
4968- cMenu = rb_define_class_under (mCurses , "Menu" , rb_cData );
4973+ cMenu = rb_define_class_under (mCurses , "Menu" , rb_cObject );
49694974 rb_define_alloc_func (cMenu , menu_s_allocate );
49704975 rb_define_method (cMenu , "initialize" , menu_initialize , 1 );
49714976 rb_define_method (cMenu , "post" , menu_post , 0 );
@@ -4988,7 +4993,7 @@ Init_curses(void)
49884993#endif
49894994
49904995#ifdef HAVE_FORM
4991- cField = rb_define_class_under (mCurses , "Field" , rb_cData );
4996+ cField = rb_define_class_under (mCurses , "Field" , rb_cObject );
49924997 rb_define_alloc_func (cField , field_s_allocate );
49934998 rb_define_method (cField , "initialize" , field_initialize , 6 );
49944999 rb_define_method (cField , "set_buffer" , field_set_buffer , 2 );
@@ -5015,7 +5020,7 @@ Init_curses(void)
50155020 rb_define_method (cField , "max=" , field_set_max , 1 );
50165021 rb_define_method (cField , "set_type" , field_set_type , -1 );
50175022
5018- cForm = rb_define_class_under (mCurses , "Form" , rb_cData );
5023+ cForm = rb_define_class_under (mCurses , "Form" , rb_cObject );
50195024 rb_define_alloc_func (cForm , form_s_allocate );
50205025 rb_define_method (cForm , "initialize" , form_initialize , 1 );
50215026 rb_define_method (cForm , "post" , form_post , 0 );
0 commit comments