Re: fixing ncurses init failed problem

new topic     » goto parent     » topic index » view thread      » older message » newer message

I talked to Elliott Sales de Andrade in the chatroom, he looked over the
ncurses source code and figured it out.

Don't need "tty -s" or other messy stuff, just use atexit() and have a global
boolean variable that is True if ncurses has been initialized and false if
it hasn't.

On further thinking, you would need 2 such variables, one for whether or not
ncurses initialiation has been attempted (variable is initialized to false,
set to true right before calling initscr()) and one for whether ncurses
was successful (variable is initialized to false, and set to true right
after initscr() returns ... if initscr() returns then it was successful,
right?). The atexit() handler would then write the ex.err if the attempted
variable was true but the success variable was false.

Maybe for 2.5, eh?

jbrown

On Fri, Jun 20, 2003 at 03:05:35PM -0400, Jim C. Brown wrote:
> I am not sure how ncurses tries to initalize the terminal, so I can't
> determine
> this with any certainty.
> 
> I know that the linux command tty (/usr/bin/tty for me) with the -s option,
> will give an exit code to tell if stdin/out/err is a terminal or not.
> 
> Using that check would allow exu to abort with an ex.err ("Attempted to
> write to screen, where screen wasn't a terminal" or something) instead of
> having ncurses just fail and die quietly.
> 
> (Since this isn't the only way ncurses can fail to initalize its terminal,
> we'd need more that just this check ... but at least its a start.)
> 
> jbrown
> 

-- 
 /"\  ASCII ribbon              | http://www.geocities.com/jbrown1050/
 \ /  campain against           | Linux User:190064
  X   HTML in e-mail and        | Linux Machine:84163
 /*\  news, and unneeded MIME   | http://verify.stanford.edu/evote.html

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu