Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Curses problem

by Sec (Monk)
on Dec 27, 2008 at 10:23 UTC ( #732771=perlquestion: print w/replies, xml ) Need Help??
Sec has asked for the wisdom of the Perl Monks concerning the following question:

This might be a problem with my understanding with Curses more than with perl, but please help me out. I'm using which works quite well except when I try to create a curses "window". Example code:
use Curses; initscr; $w=newwin(1,1,40,40); $w->addstr(20,20,"Hello"); $w->refresh; refresh; endwin;
outputs nothing, not using a window works fine:
use Curses; initscr; $w=newwin(1,1,40,40); addstr(20,20,"Hello"); refresh; endwin;

Replies are listed 'Best First'.
Re: Curses problem
by FunkyMonk (Chancellor) on Dec 27, 2008 at 11:46 UTC
    I'm never played with Curses before, but it's been on my todo list for years...

    You've got your arguments to newwin incorrect.
    $ man newwin ... WINDOW *newwin(int nlines, int ncols, int begin_y, int begin_x);

    use Curses; initscr; my $w = newwin(40,40,1,1); $w->addstr(20,20,"Hello"); $w->refresh; endwin; <>;

    Works for me.

    Update: Fixed borked link

    Unless I state otherwise, all my code runs with strict and warnings
      Duh! Thanks! Works now.
Re: Curses problem
by spadacciniweb (Deacon) on Dec 27, 2008 at 11:40 UTC
    I have changed your code:
    use Curses; initscr; $win = new Curses; $win->addstr(20, 20, 'Hello'); $win->refresh; while (1) {}; endwin;

    Update: from here I read:
    Window newWin( Int lines, Int cols, Int beginy, Int beginx ) ... lines Number of lines in window cols Number of columns in window beginy Position of top of window beginx Position of left of window
    so the correct form (with function newwin) is:
    use Curses; initscr; $win = new Curses; $win = newwin(40,40,1,1); $win->addstr(20, 20, 'Hello'); $win->refresh; while (1) {}; endwin;

    Update II: FunkyMonk has just responded before my Update:

    (($_="Mzz ojjdloobnf jt uvy5502383")=~y~b-zg2-5c96-81~a-z0-9~s)=~s~~~s; print

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://732771]
Approved by Corion
Front-paged by Corion
[choroba]: Maybe the first four got downvoted and were deleted from the list?
LanX what?
marto deletes himself from the all lists
QM deletes himself from all delete lists
LanX passes the blame to jdpatches. ..
Eily the verb from this sentence

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2018-03-20 10:12 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (249 votes). Check out past polls.