From 3704411466364bea76e0fb231cd1724f45318522 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 3 Apr 2015 20:04:19 +1300 Subject: Minimal help context for options --- libmproxy/console/__init__.py | 2 +- libmproxy/console/options.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 3b3f2df2..7e6326f7 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -472,7 +472,7 @@ class ConsoleMaster(flow.FlowMaster): options.Options(self), None, statusbar.StatusBar(self, options.footer), - None + options.help_context, ) def view_grideditor(self, ge): diff --git a/libmproxy/console/options.py b/libmproxy/console/options.py index db6cc151..e2227f08 100644 --- a/libmproxy/console/options.py +++ b/libmproxy/console/options.py @@ -2,12 +2,21 @@ import urwid from . import common, signals -help_context = None footer = [ ('heading_key', "enter/space"), ":toggle ", ('heading_key', "C"), ":clear all ", ] +def _mkhelp(): + text = [] + keys = [ + ("enter/space", "activate option"), + ("C", "clear all options"), + ] + text.extend(common.format_keyvals(keys, key="key", val="text", indent=4)) + return text +help_context = _mkhelp() + class OptionWidget(urwid.WidgetWrap): def __init__(self, option, text, shortcut, active, focus): @@ -25,12 +34,12 @@ class OptionWidget(urwid.WidgetWrap): text = common.highlight_key( text, shortcut, - textattr=textattr, - keyattr=keyattr + textattr = textattr, + keyattr = keyattr ) opt = urwid.Text(text, align="center") opt = urwid.AttrWrap(opt, textattr) - opt = urwid.Padding(opt, align="center", width=("relative", 20)) + opt = urwid.Padding(opt, align = "center", width = ("relative", 20)) urwid.WidgetWrap.__init__(self, opt) def keypress(self, size, key): -- cgit v1.2.3