Porting Perl+curses to Solaris

While porting a Curses app to Solaris (u6) the other day, I ran into a problem with the Curses::UI library. MakeMaker couldn't find the use_default_colors() function (which should be there somewhere) in the installed ncurses library headers, which Curses::UI uses by default.

It would seem that passing Curses::UI->new() an arg for -default_colors => 0 will make the library not call the use_default_colors() function, which should avoid the error. Apparently this isn't the case; I had to create my GUI with compatibility mode by using -compat => 1.

Additionally, my ncurses installation doesn't support the KEY_RESIZE constant. Fixing this was a simple tweak to the code to ignore it (the library ignores the key anyway, so it's not like I'm losing any functionality to it).

index 9ab97ae..3b39d89 100644
--- a/lib/solaris/Curses/UI.pm
+++ b/lib/solaris/Curses/UI.pm
@@ -383,9 +383,9 @@ sub do_one_event(;$)
     # ncurses sends KEY_RESIZE() key on resize. Ignore this key.
     # TODO: Try to redraw and layout everything anew
     # KEY_RESIZE doesn't seem to work right;
-    if (Curses->can("KEY_RESIZE")) {
-        $key = '-1' if $key eq KEY_RESIZE();
-    }
+#    if (Curses->can("KEY_RESIZE")) {
+#        $key = '-1' if $key eq KEY_RESIZE();
+#    }
     my ($cols,$lines) = GetTerminalSize;
     if ( ($ENV{COLS} != $cols) || ( $ENV{LINES} != $lines )) {

A quick wrapper around the original to do OS detection and pick the Curses::UI library at runtime from it, and I now have an app that'll run in curses mode on both Linux and Solaris.


No comments:

Post a Comment