Curses question

Jody Hagins hagins at dg-rtp.dg.com
Thu Nov 29 01:50:52 AEST 1990


In article <1990Nov26.222916.11634 at odin.corp.sgi.com>,
bowen at wanda.SGI.COM (Jerre Bowen) writes:
|> 
|> Michael Hart writes:
|> > 
|> > Anyway, the prog quits with a ctl-C, and is supposed to clear the
|> > screen.  I've tried werase(stdscr), wclear(stdscr), and with &
without
|> > a wrefresh(stdscr).  Am I being brain-dead, or is something funky
|> > with curses on SGI?
|> > 
|> > #include <curses.h>
|> > 
|> > main()
|> > {
|> > 	char *theStr = "Hello, World!  Using Curses!!\n";
|> > 	chtype theInput;
|> > 	int repCtr = 0;
|> > 
|> > /*	some curses initialization items first 
|> > 	init the curses code
|> > 	call character mode for input (cbreak)
|> > 	set noecho
|> > 	set to clear input buffer on an interrupt intrflus
|> > */
|> > 	initscr();
|> > 	cbreak();
|> > 	noecho();
|> > 	intrflush();
|> > 	nodelay(stdscr,TRUE);
|> > 	scrollok(stdscr,TRUE);
|> > 
|> > 	theInput = wgetch(stdscr);
|> > 	while ( theInput != KEY_END) {
|> > 		addstr(theStr);
|> > 		repCtr++;
|> > 		wprintw(stdscr,"%d \n",repCtr);
|> > 		theInput = wgetch(stdscr);
|> > 	}
|> > 	wclear(stdscr);
|> > 	wrefresh(stdscr);
|> > 	endwin();
|> > }
|> 
|> > Michael G. Hart   hart at blackjack.dt.navy.mil / 
mhart at oasys.dt.navy.mil
|> > 
|> 
|> 	cbreak() mode delivers characters to the program one by one, but
|> interrupt characters still cause signals to be sent the program, so
when
|> you <ctrl>-c the program (as you say above if I understand
correctly)
|> the process is terminated unnaturally via a SIGINT and therefore
never
|> hits the wclear() and etc.  You must catch SIGINT (using sigset(),
for
|> example) if you intend to use <ctrl>-c as the termination sequence. 
I
|> think there are other bugs in this program, however, just glancing
at
|> the curses man page--initscr() needs some parameters and I don't
think
|> using KEY_END is legit without first initializing the keypad.
|> 
|> 
|> 	Jerre Bowen
|> 	bowen at sgi.com



I believe that going into raw mode will interrupt the ctrl-c 
(and all other keys) and send them straight to the program
for processing.


--

Jody Hagins             
hagins at dg-rtp.dg.com    
Data General Corp.      
62 Alexander Dr.        
RTP, N.C.  27709        
(919) 248-6035          



More information about the Comp.lang.c mailing list