diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-04-03 14:47:55 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-04-03 14:47:55 +1300 |
commit | 41a1a0bef3b40b744c232a1adba478f8ac0f2c6c (patch) | |
tree | ad7ae044c4ceee7f5048d2c6034e7ebff3d22bae | |
parent | 57bdb893425058d03b1aaf28e1c774c81a8d9403 (diff) | |
download | mitmproxy-41a1a0bef3b40b744c232a1adba478f8ac0f2c6c.tar.gz mitmproxy-41a1a0bef3b40b744c232a1adba478f8ac0f2c6c.tar.bz2 mitmproxy-41a1a0bef3b40b744c232a1adba478f8ac0f2c6c.zip |
console: C to clear all options, correct footer in options screen
-rw-r--r-- | libmproxy/console/__init__.py | 2 | ||||
-rw-r--r-- | libmproxy/console/options.py | 30 |
2 files changed, 28 insertions, 4 deletions
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index e7776fdf..3b3f2df2 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -471,7 +471,7 @@ class ConsoleMaster(flow.FlowMaster): self, options.Options(self), None, - statusbar.StatusBar(self, help.footer), + statusbar.StatusBar(self, options.footer), None ) diff --git a/libmproxy/console/options.py b/libmproxy/console/options.py index bb6b6c09..db6cc151 100644 --- a/libmproxy/console/options.py +++ b/libmproxy/console/options.py @@ -3,6 +3,10 @@ import urwid from . import common, signals help_context = None +footer = [ + ('heading_key', "enter/space"), ":toggle ", + ('heading_key', "C"), ":clear all ", +] class OptionWidget(urwid.WidgetWrap): @@ -12,6 +16,7 @@ class OptionWidget(urwid.WidgetWrap): keyattr = "key" if focus and active: textattr = "option_active_selected" + keyattr = "option_selected_key" elif focus: textattr = "option_selected" keyattr = "option_selected_key" @@ -74,10 +79,10 @@ class OptionListBox(urwid.ListBox): self.keymap[i.shortcut] = i def keypress(self, size, key): - key = common.shortcuts(key) - if key == "enter": + if key == "enter" or key == " ": self.get_focus()[0].option.activate() return None + key = common.shortcuts(key) if key in self.keymap: self.keymap[key].activate() self.set_focus(self.options.index(self.keymap[key])) @@ -104,7 +109,7 @@ class Options(urwid.WidgetWrap): [ Option( "Anti-Cache", - "C", + "a", lambda: master.anticache, self.toggle_anticache ), @@ -156,6 +161,25 @@ class Options(urwid.WidgetWrap): ) self.master.loop.widget.footer.update("") + def keypress(self, size, key): + if key == "C": + self.clearall() + return None + return super(self.__class__, self).keypress(size, key) + + def clearall(self): + self.master.anticache = False + self.master.anticomp = False + self.master.killextra = False + self.master.showhost = False + self.master.refresh_server_playback = True + self.master.server.config.no_upstream_cert = False + signals.update_settings.send(self) + signals.status_message.send( + message = "All options cleared", + expire = 1 + ) + def toggle_anticache(self): self.master.anticache = not self.master.anticache |