console: Make global nav keys work within help

This commit is contained in:
Aldo Cortesi 2017-06-11 18:57:02 +12:00
parent fdfd3ed937
commit 926b58ab4f
2 changed files with 17 additions and 6 deletions

View File

@ -194,10 +194,6 @@ class FlowDetails(tabs.Tabs):
] ]
return searchable.Searchable(txt) return searchable.Searchable(txt)
def keypress(self, size, key):
key = super().keypress(size, key)
return self._w.keypress(size, key)
class FlowView(urwid.Frame, layoutwidget.LayoutWidget): class FlowView(urwid.Frame, layoutwidget.LayoutWidget):
keyctx = "flowview" keyctx = "flowview"

View File

@ -6,6 +6,21 @@ from mitmproxy.tools.console import layoutwidget
from mitmproxy.tools.console import tabs from mitmproxy.tools.console import tabs
class CListBox(urwid.ListBox):
def __init__(self, contents):
self.length = len(contents)
contents = contents[:] + [urwid.Text(["\n"])] * 5
super().__init__(contents)
def keypress(self, size, key):
if key == "m_end":
self.set_focus(self.length - 1)
elif key == "m_start":
self.set_focus(0)
else:
return super().keypress(size, key)
class HelpView(tabs.Tabs, layoutwidget.LayoutWidget): class HelpView(tabs.Tabs, layoutwidget.LayoutWidget):
title = "Help" title = "Help"
keyctx = "help" keyctx = "help"
@ -54,7 +69,7 @@ class HelpView(tabs.Tabs, layoutwidget.LayoutWidget):
text.extend(self.format_keys(self.master.keymap.list("global"))) text.extend(self.format_keys(self.master.keymap.list("global")))
return urwid.ListBox(text) return CListBox(text)
def filtexp_title(self): def filtexp_title(self):
return "Filter Expressions" return "Filter Expressions"
@ -83,7 +98,7 @@ class HelpView(tabs.Tabs, layoutwidget.LayoutWidget):
text.extend( text.extend(
common.format_keyvals(examples, key="key", val="text", indent=4) common.format_keyvals(examples, key="key", val="text", indent=4)
) )
return urwid.ListBox(text) return CListBox(text)
def layout_pushed(self, prev): def layout_pushed(self, prev):
""" """