From: Wolfgang Date: 2001-08-08T05:18:19+09:00 Subject: [ruby-talk:19307] Curses patch --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi! I made a tiny but useful enhancement of the curses module. Attached is a patch for Ruby 1.6.4, though it should be easy to include it in the current development version. This patch makes it possible to use terminal attributes. Cheers, Wolfgang --=20 /* Wolfgang J=E4hrling `-:._ "Omnis enim res, quae = dando * Debian GNU/Linux user && Debian GNU/Hurd user `-:. non deficit, dum hab= etur * HURD Hacking Guide: http://stdio.cjb.net/guide.txt ) et non datur, nond= um * hurd.gnu.org || www.gnu.org || www.debian.org _,-:' habetur, quomodo hab= enda * [ "Accelerate you PC - with 9.81 m/s^2" ] ,-:' est." || fsfeurope.org */ --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: attachment; filename="curses.patch" Content-Transfer-Encoding: quoted-printable --- curses.c.old Sat Aug 4 19:18:31 2001 +++ curses.c Tue Aug 7 22:48:28 2001 @@ -3,6 +3,7 @@ *=20 * by MAEDA Shugo (ender@pic-internet.or.jp) * modified by Yukihiro Matsumoto (matz@netlab.co.jp) + * modified by Wolfgang J=E4hrling (wolfgang@pro-linux.de) */ =20 #ifdef HAVE_NCURSES_H @@ -778,6 +779,45 @@ return Qnil; } =20 +/* def attron */ +static VALUE +window_attron(obj, attrs) + VALUE obj; + VALUE attrs; +{ + struct windata *winp; + + GetWINDOW(obj, winp); + wattron(winp->window, FIX2INT(attrs)); + return Qnil; +} + +/* def attron */ +static VALUE +window_attroff(obj, attrs) + VALUE obj; + VALUE attrs; +{ + struct windata *winp; + + GetWINDOW(obj, winp); + wattroff(winp->window, FIX2INT(attrs)); + return Qnil; +} + +/* def attrset */ +static VALUE +window_attrset(obj, attrs) + VALUE obj; + VALUE attrs; +{ + struct windata *winp; + + GetWINDOW(obj, winp); + wattrset(winp->window, FIX2INT(attrs)); + return Qnil; +} + /*------------------------- Initialization -------------------------*/ void Init_curses() @@ -816,6 +856,14 @@ rb_define_module_function(mCurses, "deleteln", curses_deleteln, 0); rb_define_module_function(mCurses, "lines", curses_lines, 0); rb_define_module_function(mCurses, "cols", curses_cols, 0); + + rb_define_const(mCurses, "NORMAL", INT2FIX(A_NORMAL)); + rb_define_const(mCurses, "STANDOUT", INT2FIX(A_STANDOUT)); + rb_define_const(mCurses, "UNDERLINE", INT2FIX(A_UNDERLINE)); + rb_define_const(mCurses, "REVERSE", INT2FIX(A_REVERSE)); + rb_define_const(mCurses, "BLINK", INT2FIX(A_BLINK)); + rb_define_const(mCurses, "DIM", INT2FIX(A_DIM)); + rb_define_const(mCurses, "BOLD", INT2FIX(A_BOLD)); =20 cWindow =3D rb_define_class_under(mCurses, "Window", rb_cObject); rb_define_singleton_method(cWindow, "new", window_s_new, 4); @@ -843,6 +891,9 @@ rb_define_method(cWindow, "getstr", window_getstr, 0); rb_define_method(cWindow, "delch", window_delch, 0); rb_define_method(cWindow, "deleteln", window_deleteln, 0); + rb_define_method(cWindow, "attron", window_attron, 1); + rb_define_method(cWindow, "attroff", window_attroff, 1); + rb_define_method(cWindow, "attrset", window_attrset, 1); =20 rb_set_end_proc(curses_finalize, 0); } --tKW2IUtsqtDRztdT--