From 3a148491e73ce13e07e1cf96825d2c12b5b59396 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sun, 2 Oct 2011 19:22:37 +0100 Subject: cleanup and fix issue with non-set current_buffer --- alot/ui.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'alot') diff --git a/alot/ui.py b/alot/ui.py index 7bf5ed7b..6a5d8b61 100644 --- a/alot/ui.py +++ b/alot/ui.py @@ -18,7 +18,7 @@ Copyright (C) 2011 Patrick Totzke """ import urwid from urwid.command_map import command_map -from twisted.internet import defer +from twisted.internet import reactor, defer from settings import config from buffer import BufferlistBuffer @@ -98,10 +98,9 @@ class UI(object): :returns: a `twisted.defer.Deferred` """ d = defer.Deferred() # create return deferred - main = self.mainloop.widget # save main widget def select_or_cancel(text): - self.mainloop.widget = main # restore main screen + self.mainloop.widget = self.mainframe # restore main screen d.callback(text) #set up widgets @@ -121,7 +120,7 @@ class UI(object): urwid.AttrMap(both, 'prompt', 'prompt') # put promptwidget as overlay on main widget - overlay = urwid.Overlay(both, main, + overlay = urwid.Overlay(both, self.mainframe, ('fixed left', 0), ('fixed right', 0), ('fixed bottom', 1), @@ -129,6 +128,10 @@ class UI(object): self.mainloop.widget = overlay return d # return deferred + def exit(self): + reactor.stop() + raise urwid.ExitMainLoop() + @defer.inlineCallbacks def commandprompt(self, startstring): """prompt for a commandline and interpret/apply it upon enter @@ -323,7 +326,8 @@ class UI(object): def clear(*args): self.clear_notify(msgs) - self.mainloop.draw_screen() + # TODO: replace this with temporarily wrapping self.mainframe + # in a ui.show_root_until_keypress.. if block: self.mainloop.screen.get_input() clear() @@ -343,10 +347,16 @@ class UI(object): #h=urwid.AttrMap(head, 'header') #self.mainframe.set_header(h) - #body - self.mainframe.set_body(self.current_buffer) + # body + if self.current_buffer: + self.mainframe.set_body(self.current_buffer) + else: + # this happens iff update gets called during + # initial command before a first buffer is displayed. + # in compose, a prompt is cancelled + self.exit() - #footer + # footer lines = [] if self.notificationbar: # .get_text()[0] != ' ': lines.append(self.notificationbar) -- cgit v1.2.3