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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.