summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-04 22:35:32 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-04 22:35:32 +0100
commit52bfe9b87e105534baf2c32f1bcf423c4b665f77 (patch)
treefee98dd5836105ad2209610cfbbcfa3253b3755d
parent7f34ac866544086b63682edbbe028c42be664663 (diff)
rework main keypress for relaying
-rw-r--r--alot/ui.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/alot/ui.py b/alot/ui.py
index 6a5d8b61..2cf03b1d 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -33,15 +33,18 @@ class MainWidget(urwid.Frame):
urwid.Frame.__init__(self, urwid.SolidFill(), *args, **kwargs)
self.ui = ui
- def keypress(self, size, key):
- self.ui.logger.debug('got key: %s' % key)
- cmdline = config.get_mapping(self.ui.mode, key)
- if cmdline:
- cmd = interpret_commandline(cmdline, self.ui.mode)
- if cmd:
- self.ui.apply_command(cmd)
- else:
- urwid.Frame.keypress(self, size, key)
+ def keypress(self, size, key, interpret=True):
+ self.ui.logger.debug('got key: \'%s\'' % key)
+ if interpret:
+ cmdline = config.get_mapping(self.ui.mode, key)
+ if cmdline:
+ cmd = interpret_commandline(cmdline, self.ui.mode)
+ if cmd:
+ self.ui.apply_command(cmd)
+ return None
+ self.ui.logger.debug('relaying key: %s' % key)
+ return urwid.Frame.keypress(self, size, key)
+
class UI(object):
@@ -62,7 +65,7 @@ class UI(object):
config.get_palette(),
handle_mouse=False,
event_loop=urwid.TwistedEventLoop(),
- unhandled_input=self.keypress)
+ unhandled_input=self.unhandeled_input)
self.mainloop.screen.set_terminal_properties(colors=colourmode)
self.show_statusbar = config.getboolean('general', 'show_statusbar')
@@ -70,7 +73,7 @@ class UI(object):
self.mode = 'global'
self.commandprompthistory = []
- self.logger.debug('setup bindings')
+ #self.logger.debug('setup bindings')
for key, value in config.items('urwid-maps'):
command_map[key] = value
@@ -78,9 +81,12 @@ class UI(object):
self.apply_command(initialcmd)
self.mainloop.run()
- def keypress(self, key):
+ def unhandeled_input(self, key):
self.logger.debug('unhandeled input: %s' % key)
+ def keypress(self, key):
+ self.mainloop.widget.keypress((150,20), key, interpret=False)
+
def prompt(self, prefix='>', text=u'', completer=None, tab=0, history=[]):
"""prompt for text input