Move ncurses code into a set of classes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
This commit is contained in:
brian m. carlson 2011-09-08 15:24:37 -05:00
parent a2829333fc
commit a56f094d0c

23
newfol
View file

@ -55,11 +55,12 @@ def convert_color(x):
locale.setlocale(locale.LC_ALL, '')
def start_curses():
palette = [
('bg', 'black', 'yellow', '', 'black', '#ffa'),
('text', 'black', 'yellow', '', '#860', '#ffa'),
]
class View:
def render(self, loop):
pass
class IntroView(View):
def render(self, loop):
intro1 = urwid.Text(("text", "newfol " + __version__), align="center")
intro2 = urwid.Text(("text", "Press q to quit at any time."),
align="center")
@ -68,12 +69,22 @@ def start_curses():
urwid.AttrMap(intro2, "bg")])
fill = urwid.Filler(pile)
map2 = urwid.AttrMap(fill, "bg")
loop.widget = map2
def start_curses():
palette = [
('bg', 'black', 'yellow', '', 'black', '#ffa'),
('text', 'black', 'yellow', '', '#860', '#ffa'),
]
def exit_on_q(inp):
if inp in ('q', 'Q'):
raise urwid.ExitMainLoop()
loop = urwid.MainLoop(map2, palette, unhandled_input=exit_on_q)
intro = IntroView()
loop = urwid.MainLoop(None, palette, unhandled_input=exit_on_q)
loop.screen.set_terminal_properties(colors=256)
intro.render(loop)
loop.run()
def load_schemata():