From: Giancarlo F Bellido Date: 2008-12-09T03:14:25+09:00 Subject: [ruby-core:20434] Another Patch for curses extension. This is a multipart message in MIME format. ------=_NextPart_000_0754_01C95937.FA226040 Content-Type: text/plain; charset="us-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 ------=_NextPart_000_0754_01C95937.FA226040 Content-Type: application/octet-stream; name="patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patch" Index: curses.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= --- curses.c (revision 20439)=0A= +++ curses.c (working copy)=0A= @@ -416,11 +416,7 @@=0A= curses_stdscr();=0A= c =3D getch();=0A= if (c =3D=3D EOF) return Qnil;=0A= - if (ISPRINT(c)) {=0A= - char ch =3D (char)c;=0A= -=0A= - return rb_locale_str_new(&ch, 1);=0A= - }=0A= + =0A= return UINT2NUM(c);=0A= }=0A= =0A= @@ -499,6 +495,12 @@=0A= return INT2FIX(COLS);=0A= }=0A= =0A= +/**=0A= + * Sets Cursor Visibility.=0A= + * 0: invisible=0A= + * 1: visible=0A= + * 2: very visible=0A= + */=0A= static VALUE=0A= curses_curs_set(VALUE obj, VALUE visibility)=0A= {=0A= @@ -573,6 +575,38 @@=0A= }=0A= =0A= static VALUE=0A= +curses_use_default_colors(VALUE obj)=0A= +{=0A= +#if defined(HAVE_USE_DEFAULT_COLORS)=0A= + use_default_colors();=0A= + return Qnil;=0A= +#else=0A= + rb_notimplement();=0A= +#endif=0A= +}=0A= +=0A= +static VALUE=0A= +curses_tabsize_set(VALUE obj, VALUE val)=0A= +{=0A= +#if defined(HAVE_TABSIZE)=0A= + TABSIZE=3DNUM2INT(val);=0A= + return INT2NUM(TABSIZE);=0A= +#else=0A= + rb_notimplement();=0A= +#endif=0A= +}=0A= +=0A= +static VALUE=0A= +curses_tabsize_get(VALUE ojb)=0A= +{=0A= +#if defined(HAVE_TABSIZE)=0A= + return INT2NUM(TABSIZE);=0A= +#else=0A= + rb_notimplement();=0A= +#endif=0A= +}=0A= +=0A= +static VALUE=0A= curses_escdelay_set(VALUE obj, VALUE val)=0A= {=0A= #if defined(HAVE_ESCDELAY)=0A= @@ -1131,11 +1165,7 @@=0A= GetWINDOW(obj, winp);=0A= c =3D wgetch(winp->window);=0A= if (c =3D=3D EOF) return Qnil;=0A= - if (ISPRINT(c)) {=0A= - char ch =3D (char)c;=0A= =0A= - return rb_locale_str_new(&ch, 1);=0A= - }=0A= return UINT2NUM(c);=0A= }=0A= =0A= @@ -1442,6 +1472,10 @@=0A= =0A= rb_define_module_function(mCurses, "ESCDELAY=3D", = curses_escdelay_set, 1);=0A= rb_define_module_function(mCurses, "ESCDELAY", curses_escdelay_get, = 0);=0A= + rb_define_module_function(mCurses, "TABSIZE", curses_tabsize_get, = 0);=0A= + rb_define_module_function(mCurses, "TABSIZE=3D", = curses_tabsize_set, 1);=0A= +=0A= + rb_define_module_function(mCurses, "use_default_colors", = curses_use_default_colors, 0);=0A= rb_define_module_function(mCurses, "init_screen", = curses_init_screen, 0);=0A= rb_define_module_function(mCurses, "close_screen", = curses_close_screen, 0);=0A= rb_define_module_function(mCurses, "closed?", curses_closed, 0);=0A= Index: extconf.rb=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= --- extconf.rb (revision 20574)=0A= +++ extconf.rb (working copy)=0A= @@ -21,7 +21,7 @@=0A= end=0A= =0A= if make=0A= - 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)=0A= + 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)=0A= have_func(f) || (have_macro(f, curses) && = $defs.push(format("-DHAVE_%s", f.upcase)))=0A= end=0A= flag =3D "-D_XOPEN_SOURCE_EXTENDED"=0A= @@ -29,5 +29,6 @@=0A= $defs << flag=0A= end=0A= have_var("ESCDELAY", curses)=0A= + have_var("TABSIZE", curses)=0A= create_makefile("curses")=0A= end=0A= ------=_NextPart_000_0754_01C95937.FA226040--