diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-10-01 21:29:21 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-10-01 21:29:21 +0100 |
commit | 55b55165a7d3555abc91a92ee642259e119fff23 (patch) | |
tree | 485d15e54daf03b40baa2d2bbd16ba475854e17a | |
parent | 7a431af0d8418a89fd4cbee19b9986c754ae6d8e (diff) |
add machanism to replace root until keypress
-rw-r--r-- | alot/ui.py | 6 | ||||
-rw-r--r-- | alot/widgets.py | 16 |
2 files changed, 22 insertions, 0 deletions
@@ -82,6 +82,12 @@ class UI(object): def keypress(self, key): self.logger.debug('unhandeled input: %s' % key) + def show_as_root_until_keypress_(self, w, key): + def oe(): + self.mainloop.widget = self.mainframe # restore main screen + self.mainloop.widget = widgets.CatchKeyWidgetWrap(w, key, + on_catch=oe) + def prompt(self, prefix='>', text=u'', completer=None, tab=0, history=[]): """prompt for text input diff --git a/alot/widgets.py b/alot/widgets.py index ab19827f..d17bbfc3 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -52,6 +52,22 @@ class DialogBox(urwid.WidgetWrap): return self.body.keypress(size, key) +class CatchKeyWidgetWrap(urwid.WidgetWrap): + def __init__(self, widget, key, on_catch): + urwid.WidgetWrap.__init__(self, widget) + self.key = key + self.on_catch = on_catch + + def selectable(self): + return True + + def keypress(self, size, key): + if command_map[key] == self.key: + self.on_catch() + elif self._w.selectable(): + return self._w.keypress(size, key) + + class ThreadlineWidget(urwid.AttrMap): def __init__(self, tid, dbman): self.dbman = dbman |