This is a multipart message in MIME format. ------ extPart_000_0754_01C95937.FA226040 Content-Type: text/plain; charset s-ascii" Content-Transfer-Encoding: 7bit Hello, This is a patch for the ruby curses extension. It adds a couple of missing functions and also it fixes a bug in getch that prevents special keys like INSERT or DELETE to be returned when keypad is enabled. There is a problem with Unicode characters and key codes returned by getch. - Adds TABSIZE variable. - Adds use_default_colors function. - Fixes Curses.getch and Window::getch. - Adds relevant lines to extconf.rb Thank you giancarlo ------ extPart_000_0754_01C95937.FA226040 Content-Type: application/octet-stream; name atch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename atch" Index: curses.c =================================================================== --- curses.c (revision 20439) +++ curses.c (working copy) @@ -416,11 +416,7 @@ urses_stdscr(); 3D getch(); f (c == EOF) return Qnil; - if (ISPRINT(c)) { - char ch = (char)c; - - return rb_locale_str_new(&ch, 1); - } + eturn UINT2NUM(c); 0A@@ -499,6 +495,12 @@ eturn INT2FIX(COLS); 0A+/** + * Sets Cursor Visibility. + * 0: invisible + * 1: visible + * 2: very visible + */ tatic VALUE urses_curs_set(VALUE obj, VALUE visibility) @@ -573,6 +575,38 @@ 0Atatic VALUE +curses_use_default_colors(VALUE obj) +{ +#if defined(HAVE_USE_DEFAULT_COLORS) + use_default_colors(); + return Qnil; +#else + rb_notimplement(); +#endif +} + +static VALUE +curses_tabsize_set(VALUE obj, VALUE val) +{ +#if defined(HAVE_TABSIZE) + TABSIZE=NUM2INT(val); + return INT2NUM(TABSIZE); +#else + rb_notimplement(); +#endif +} + +static VALUE +curses_tabsize_get(VALUE ojb) +{ +#if defined(HAVE_TABSIZE) + return INT2NUM(TABSIZE); +#else + rb_notimplement(); +#endif +} + +static VALUE urses_escdelay_set(VALUE obj, VALUE val) if defined(HAVE_ESCDELAY) @@ -1131,11 +1165,7 @@ etWINDOW(obj, winp); 3D wgetch(winp->window); f (c == EOF) return Qnil; - if (ISPRINT(c)) { - char ch = (char)c; 0A- return rb_locale_str_new(&ch, 1); - } eturn UINT2NUM(c); 0A@@ -1442,6 +1472,10 @@ 0Ab_define_module_function(mCurses, "ESCDELAY=", curses_escdelay_set, 1); b_define_module_function(mCurses, "ESCDELAY", curses_escdelay_get, 0); + rb_define_module_function(mCurses, "TABSIZE", curses_tabsize_get, 0); + rb_define_module_function(mCurses, "TABSIZE=", curses_tabsize_set, 1); + + rb_define_module_function(mCurses, "use_default_colors", curses_use_default_colors, 0); b_define_module_function(mCurses, "init_screen", curses_init_screen, 0); b_define_module_function(mCurses, "close_screen", curses_close_screen, 0); b_define_module_function(mCurses, "closed?", curses_closed, 0); Index: extconf.rb =================================================================== --- extconf.rb (revision 20574) +++ extconf.rb (working copy) @@ -21,7 +21,7 @@ nd 0Af make - for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay init_color wcolor_set) + for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay init_color wcolor_set use_default_colors) ave_func(f) || (have_macro(f, curses) && $defs.push(format("-DHAVE_%s", f.upcase))) nd lag = "-D_XOPEN_SOURCE_EXTENDED" @@ -29,5 +29,6 @@ defs << flag nd ave_var("ESCDELAY", curses) + have_var("TABSIZE", curses) reate_makefile("curses") nd ----- extPart_000_0754_01C95937.FA226040--