Problem with Curses

B

Babacio

Hi,

Sorry if the question looks stupid to some of you...

Here is a piece of code:
####################################
use Curses;

initscr();
# here I should use curses
endwin();

print "Hello!\n";
print "What do you say? ";
$x=<STDIN>;
print "You said $x\n";
#####################################

The functions initscr() and endwin() are to be use before and after
doing stuff with curses...

When I run it (on Mac OS X / darwin), I have the following problem :
the text of the three prints does not appear until the end of the
program, so I enter the value of $x with nothing printed, and
after that the three line appear.

This is due to some pertubation Curses makes in the terminal.

This second piece of code sort of give a solution to this problem:

####################################
use Curses;
use IO::Handle;

initscr();
# here I should use curses
endwin();

STDOUT->autoflush(1); # or $|=1

print "Hello!\n";
print "What do you say? ";
$x=<STDIN>;
print "\nYou said $x\n";
#####################################

Forcing STDOUT to flush contiuously, the behaviour is (seems to be)
what is expected.

But it is obvious that this in not the right way to solve the
problem. The vale of $| should remain 0.

Any idea?
 
B

Babacio

Babacio.
Hi,

Sorry if the question looks stupid to some of you...

Here is a piece of code:
####################################
use Curses;

initscr();
# here I should use curses
endwin();

print "Hello!\n";
print "What do you say? ";
$x=<STDIN>;
print "You said $x\n";
#####################################

The functions initscr() and endwin() are to be use before and after
doing stuff with curses...

When I run it (on Mac OS X / darwin), I have the following problem :
the text of the three prints does not appear until the end of the
program, so I enter the value of $x with nothing printed, and
after that the three line appear.

(...)

Even if you don't have a solution, could you at least tell me if the
behaviour is the same on other systems (Linux, FreeBSD) ?

Thanks.
 
I

Ian Wilson

Babacio said:
Babacio.




Even if you don't have a solution, could you at least tell me if the
behaviour is the same on other systems (Linux, FreeBSD) ?

$ uname
Linux
$ ./curses.pl
Can't locate curses.pm in @INC

Maybe you should say where you got Curses.pm and which version you are
using?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top