Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!sdd.hp.com!elroy.jpl.nasa.gov!ames!sgi!shinobu!odin!wanda!bowen From: bowen@wanda.SGI.COM (Jerre Bowen) Newsgroups: comp.lang.c Subject: Re: Curses question Message-ID: <1990Nov26.222916.11634@odin.corp.sgi.com> Date: 26 Nov 90 22:29:16 GMT References: Sender: news@odin.corp.sgi.com (Net News) Reply-To: bowen@wanda.SGI.COM (Jerre Bowen) Distribution: na Organization: Silicon Graphics Inc. Lines: 57 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 > > 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@blackjack.dt.navy.mil / mhart@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 -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 -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@sgi.com