[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Restarting Curses
From: |
Tim Mooney |
Subject: |
Re: Restarting Curses |
Date: |
Thu, 3 Sep 2009 14:55:16 -0500 (CDT) |
In regard to: Restarting Curses, Nicholas Cole said (at 3:30pm on Sep 3, 2009):
Dear Curses List,
I have a strange problem. I have code that can start up and close
down curses making sure the terminal is reset. But if I call it a
second time, the terminal is not properly reset. I'm using python,
but I suspect it would be the same in C. What might I be doing wrong?
It's been years and years since I've done any curses programming so I'm
a little rusty, but I do remember this hard-learned lesson: you only want
to call initscr() ONCE per program.
I'm sure others can correct me on this, but if you need to "shell out" of
your curses app for a while, you do want to call endwin(). When you're
ready to come back to your curses app, I believe just a
"refresh()/wrefresh()/doupdate()" will do what you need. I used
refresh() and that worked perfectly for the curses-based menu system I was
modifying.
PS: Looking at the source code for the curses-based app I worked on, it's
been 14 years since I last did any real curses programming, yet I still
remember the initscr() lesson. ;-)
Tim
Python curses provides a wrapper function precisely for the purpose of
setting up the terminal and then resetting it, and the same behaviour
happens whether I use that or set up curses myself.
Minimal code looks something like:
#def wrapper(call_function):
# locale.setlocale(locale.LC_ALL, '')
# screen = curses.initscr()
# curses.noecho()
# curses.cbreak()
#
# return_code = call_function(screen)
#
# curses.nocbreak()
# curses.echo()
# curses.endwin()
As I say, it seems to work the first time it is called, but not the
second. Any insights?
--
Tim Mooney address@hidden
Enterprise Computing & Infrastructure 701-231-1076 (Voice)
Room 242-J6, IACC Building 701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164
- Restarting Curses, Nicholas Cole, 2009/09/03
- Re: Restarting Curses,
Tim Mooney <=
- Re: Restarting Curses, Nicholas Cole, 2009/09/03
- Re: Restarting Curses, Thomas Dickey, 2009/09/03
- Re: Restarting Curses, Tim Mooney, 2009/09/03
- Re: Restarting Curses, Nicholas Cole, 2009/09/05
- Re: Restarting Curses, Thomas Dickey, 2009/09/05
- Re: Restarting Curses, Nicholas Cole, 2009/09/05
- Re: Restarting Curses, Nicholas Cole, 2009/09/05