Tweak curses.wrapper so it initializes colors if they are available.

This commit is contained in:
Eric S. Raymond 2000-08-09 21:11:07 +00:00
parent 46a4151674
commit 1ebd3f6c4b
3 changed files with 20 additions and 4 deletions

View file

@ -32,6 +32,15 @@ def wrapper(func, *rest):
# a special value like curses.KEY_LEFT will be returned
stdscr.keypad(1)
# Start color, too. Harmless if the terminal doesn't have
# color; user can test with has_color() later on. The try/catch
# works around a minor bit of over-conscientiousness in the curses
# module -- the error return from C start_color() is ignorable.
try:
curses.start_color()
except:
pass
res = apply(func, (stdscr,) + rest)
except:
# In the event of an error, restore the terminal