[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

9907.0. "curses program behavior changed 3.2 to 4.0" by ANDICE::DALEY ('Course it don't come with @!# wafers!) Wed May 21 1997 13:10

Hello,

This has to do with v4.0, curses, and reverse video.

The following program works ok on v3.2g, but when compiled on 4.0b it acts
strangely ... You have to explicitly type ^j to get it to display a reverse
video string, then exit.  On 3.2g (using the old libcurses), the return key
works.

Do we provide any detailed documentation on what could be done with curses
prior to dUNIX 4.0 that can't be done now?  My customer is moving curses
programs to 4.0, and the binaries run...but when he changes something and
rebuilds, things fall apart.

Thanks for any attention.  Here's the code:
-------------------------------------------

#include <curses.h>


char buf[20];

main ()



{
   initscr();
   attron ( A_REVERSE );
   addstr ( "This should be visible!!!" );
   gets(buf);
   attroff ( A_REVERSE );
   refresh();
   resetterm();
   endwin();

} /* End of main() */
T.RTitleUserPersonal
Name
DateLines
9907.1Change getc(buf) to getch()ANDICE::DALEY&#039;Course it don&#039;t come with @!# wafers!Tue May 27 1997 13:1114
If you change getc(buf) to getch() the program in .0 works. 

My customer has since decided to go with ncurses instead of XPG4 curses
because it's more what like he knows.

What's the best documentation for someone running 3.2 with a heavy reliance 
on older curses function who is upgrading to 4.0?  

The X/Open CAE Specification, X/Open Curses, Issue 4, 1995 ?  Are there any
books, tutorials, etc anyone has run across?

Thanks,

John 
9907.24.0 curses library behavior changesNNTPD::&quot;[email protected]&quot;[email protected]Thu May 29 1997 15:3129
As the prior reply noted, if you replace gets() with a curses i/o 
function, the program works correctly.  The reason is that the new
curses lib takes control of the tty from the time initscr() is called
to the completion of endwin().   Changes are made to the tty settings
to allow curses to do its thing and it is expected that all i/o be
performed through the curses routines.  Functions outside the curses
lib are unaware of the tty changes, be unable to complete their tasks,
and the application will exhibit this type of behavior.

The old curses library (3.2 and prior) was more forgiving and instead
of taking control of the tty, more or less shared it.  Thus, programs
such as the one in .0 worked as expected.  The downside of this 
approach was that if the application changed the tty settings to
something other than what curses expected, then curses could fail.

So, as a general rule for anyone porting curses code to 4.0 or later,
once initscr() is called, use curses lib functions for all i/o
opperations.  After endwin() has been called, the tty will be restored
to its initial state and all control returned to the application.

I hope this helps.

Bob Fontaine
Digital UNIX Engineering



[Posted by WWW Notes gateway]