Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Curses problem

by Sec (Scribe)
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 (Canon) 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
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2017-08-18 02:28 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (294 votes). Check out past polls.