J
Joe Keen
I'm working on a small curses application that opens an external
editor occasionally; in the current case I'm testing its running vi.
Once I exit vi and return to the curses application I lose the
background color, window frames, and any text I had on the screen
before I opened vi. I can still see the program functioning though as
it is still responding to key strokes and still updating small
portions of the screen. I'm obviously doing something wrong but so
far I haven't been able to figure out what from the documentation.
I've boiled the problem I'm seeing down to a relatively small program:
import curses
import os
def vitest():
os.system('vi /tmp/foo_bar_baz');
return 1
def quit():
return 0
def nocommand():
return 1
command_table = { 'a' : vitest,
'q' : quit}
def refresh():
screen.refresh()
def keyhandler():
key = screen.getkey()
result = command_table.get(key,nocommand)()
screen.addstr(1,1,"Got: "+key)
return result
def main(stdscr):
global navigation, text, screen
screen = stdscr
screen.border()
screen.addstr(0,1," Test Window ")
refresh()
while keyhandler():
refresh()
curses.wrapper(main)
editor occasionally; in the current case I'm testing its running vi.
Once I exit vi and return to the curses application I lose the
background color, window frames, and any text I had on the screen
before I opened vi. I can still see the program functioning though as
it is still responding to key strokes and still updating small
portions of the screen. I'm obviously doing something wrong but so
far I haven't been able to figure out what from the documentation.
I've boiled the problem I'm seeing down to a relatively small program:
import curses
import os
def vitest():
os.system('vi /tmp/foo_bar_baz');
return 1
def quit():
return 0
def nocommand():
return 1
command_table = { 'a' : vitest,
'q' : quit}
def refresh():
screen.refresh()
def keyhandler():
key = screen.getkey()
result = command_table.get(key,nocommand)()
screen.addstr(1,1,"Got: "+key)
return result
def main(stdscr):
global navigation, text, screen
screen = stdscr
screen.border()
screen.addstr(0,1," Test Window ")
refresh()
while keyhandler():
refresh()
curses.wrapper(main)