[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

newterm problem

From: Steven Woody
Subject: newterm problem
Date: Thu, 10 Apr 2008 15:49:58 +0800

The problem is,  in using of newterm( TERM, outfd, infd ), if

 1, if outfd and infd are same reference to a same terminal, everything
 seems fine.
 2, if outfd and infd are referering to different terminal, the
 cbreak() and noecho() will not take effect.

 You can check out the simple code listed in the last and run with
 something like:

 $ mytest  /dev/pts/0 /dev/pts/0
 $ mytest /dev/pts/0 dev/pts/1

 For the both cases, the `mytest' program is running on /dev/pts/0. In
 the second case,  you have to switch to another terminal (/dev/pts/1)
 to do input, and see the outputs in /dev/pts/0.  The result is, in the
 first case, everything is fine, but in the second case, the input can
 not immediately received by `mytest', hence there is nothing to print
 before you press an `enter' key.

 Could anyone please explain this strange phenomena for me? Where I
 made any error?


 ---------------- mytest.c ------------------------------

 #include <ncurses.h>
 #include <string.h>
 #include <assert.h>

 int main( const int argc, char *argv[] )
   assert( argc == 3 );

   char mesg[]="Enter a string: ";
   char str[80];
   int row,col;

   FILE *in = fopen( argv[ 1 ], "r" );
   FILE *out = fopen( argv[ 2 ], "w" );
   if ( in == NULL & out == NULL )
       return 1;

   SCREEN *s = newterm( "linux", out, in );
   if ( s == NULL )
       return 2;
   if ( set_term( s ) == NULL )
       return 3;

   while( true ) {
       char c = getch();
       if ( c == 'q' )
       printw( "%c", c );

   delscreen( s );

   return 0;
 ------------------------- end -------------------------------------------------


then sun rose thinly from the sea and the old man could see the other
boats, low on the water and well in toward the shore, spread out
across the current.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]