Fix multi-key handling at top level

The example for multi-key handling, setting quit to ":q", did not
work because the key buffer clearing at the project screen was
interfering with the key buffering for unhandled input at the top
level.  Correct this by only clearing the keybuffer in the project
screen if that screen handled a command.  Otherwise, let the
unhandled input handler clear it if necessary.

Change-Id: I104141ceaa87e6178ca74467a55cb7a944ad0128
This commit is contained in:
James E. Blair 2015-12-19 12:29:16 -08:00
parent 96a29dae9b
commit f21f085d20
1 changed files with 13 additions and 6 deletions

View File

@ -156,16 +156,22 @@ class ProjectListView(urwid.WidgetWrap):
key = super(ProjectListView, self).keypress(size, key)
keys = self.app.input_buffer + [key]
commands = self.app.config.keymap.getCommands(keys)
if not self.app.input_buffer and keymap.FURTHER_INPUT not in commands:
self.app.clearInputBuffer()
ret = self.handleCommands(commands)
if ret is True:
if keymap.FURTHER_INPUT not in commands:
self.app.clearInputBuffer()
return None
return key
def handleCommands(self, commands):
if keymap.TOGGLE_LIST_REVIEWED in commands:
self.unreviewed = not self.unreviewed
self.refresh()
return None
return True
if keymap.TOGGLE_LIST_SUBSCRIBED in commands:
self.subscribed = not self.subscribed
self.refresh()
return None
return True
if keymap.TOGGLE_SUBSCRIBED in commands:
if not len(self.listbox.body):
return None
@ -180,5 +186,6 @@ class ProjectListView(urwid.WidgetWrap):
self.app.sync.submitTask(
sync.SyncSubscribedProjectsTask(sync.HIGH_PRIORITY))
self.app.status.update()
return None
return key
self.refresh()
return True
return False