I have a command line tool that needs to be take on a spiffed-up UI. So I figured this would be a good time to get to know Curses.
The following script works as desired. It clears the screen, displays "foo" in the appropriate place. And then restores the console screen as it was before the program ran.
#!/usr/bin/perl -w
use strict;
use Curses;
initscr();
addstr(10, 10, "foo");
refresh();
sleep 2;
endwin();
On the other hand, this next script is less well-behaved. After displaying "foo" and waiting 2 seconds, it complains
"Curses function 'endwin' called with too many arguments at ./curses.pl line 10." and then leaves the console session in what I would describe as no_echo, no_eol mode (blindly typing 'ls -l' gives me a dir listing with no eol chars).
#!/usr/bin/perl -w
use strict;
use Curses;
initscr(); # omit this line for same result
my $win = new Curses;
#$win->initscr(); # including this causes no display
$win->addstr(10, 10, 'foo');
$win->refresh();
sleep 2;
$win->endwin();
I would be glad for...
- An explanation of why script #2 is messing up
- A clue as to how to fix it
- A reference to some docs that really explain the various Curses functions and how to use this module's OO style properly. (I have read 'perldoc Curses' and 'man Curses' as well as several Googled pages and just get the run-around.)
TIA,
David