From 5f23158143d6e9175ac648f84d09e86391885e20 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 11 Apr 2020 11:55:27 +0530 Subject: [PATCH 1/3] add common keybindings --- mitmproxy/tools/console/defaultkeys.py | 16 ++++++++-------- mitmproxy/tools/console/flowview.py | 2 +- mitmproxy/tools/console/help.py | 14 +++++++++++++- mitmproxy/tools/console/keymap.py | 1 + 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/mitmproxy/tools/console/defaultkeys.py b/mitmproxy/tools/console/defaultkeys.py index a0f276252..8954a492d 100644 --- a/mitmproxy/tools/console/defaultkeys.py +++ b/mitmproxy/tools/console/defaultkeys.py @@ -1,14 +1,14 @@ def map(km): - km.add(":", "console.command ", ["global"], "Command prompt") - km.add("?", "console.view.help", ["global"], "View help") + km.add(":", "console.command ", ["commonkey", "global"], "Command prompt") + km.add("?", "console.view.help", ["commonkey","global"], "View help") km.add("B", "browser.start", ["global"], "Start an attached browser") km.add("C", "console.view.commands", ["global"], "View commands") km.add("K", "console.view.keybindings", ["global"], "View key bindings") - km.add("O", "console.view.options", ["global"], "View options") - km.add("E", "console.view.eventlog", ["global"], "View event log") - km.add("Q", "console.exit", ["global"], "Exit immediately") - km.add("q", "console.view.pop", ["global"], "Exit the current view") + km.add("O", "console.view.options", ["commonkey", "global"], "View options") + km.add("E", "console.view.eventlog", ["commonkey", "global"], "View event log") + km.add("Q", "console.exit", ["commonkey", "global"], "Exit immediately") + km.add("q", "console.view.pop", ["commonkey", "global"], "Exit the current views") km.add("-", "console.layout.cycle", ["global"], "Cycle to next layout") km.add("shift tab", "console.panes.next", ["global"], "Focus next layout pane") km.add("ctrl right", "console.panes.next", ["global"], "Focus next layout pane") @@ -20,8 +20,8 @@ def map(km): km.add("j", "console.nav.down", ["global"], "Down") km.add("l", "console.nav.right", ["global"], "Right") km.add("h", "console.nav.left", ["global"], "Left") - km.add("tab", "console.nav.next", ["global"], "Next") - km.add("enter", "console.nav.select", ["global"], "Select") + km.add("tab", "console.nav.next", ["commonkey", "global"], "Next") + km.add("enter", "console.nav.select", ["commonkey", "global"], "Select") km.add("space", "console.nav.pagedown", ["global"], "Page down") km.add("ctrl f", "console.nav.pagedown", ["global"], "Page down") km.add("ctrl b", "console.nav.pageup", ["global"], "Page up") diff --git a/mitmproxy/tools/console/flowview.py b/mitmproxy/tools/console/flowview.py index 2fa1df1f2..fd41da0d0 100644 --- a/mitmproxy/tools/console/flowview.py +++ b/mitmproxy/tools/console/flowview.py @@ -126,7 +126,7 @@ class FlowDetails(tabs.Tabs): self.master.log.debug(error) # Give hint that you have to tab for the response. if description == "No content" and isinstance(message, http.HTTPRequest): - description = "No request content (press tab to view response)" + description = "No request content" # If the users has a wide terminal, he gets fewer lines; this should not be an issue. chars_per_line = 80 diff --git a/mitmproxy/tools/console/help.py b/mitmproxy/tools/console/help.py index fb4e00518..5a7bbb9a9 100644 --- a/mitmproxy/tools/console/help.py +++ b/mitmproxy/tools/console/help.py @@ -51,10 +51,22 @@ class HelpView(tabs.Tabs, layoutwidget.LayoutWidget): text = [ urwid.Text( [ + ("title", "Common Keybindings") + ] + ) + + ] + + text.extend(self.format_keys(self.master.keymap.list("commonkey"))) + + text.append( + urwid.Text( + [ + "\n", ("title", "Keybindings for this view") ] ) - ] + ) if self.helpctx: text.extend(self.format_keys(self.master.keymap.list(self.helpctx))) diff --git a/mitmproxy/tools/console/keymap.py b/mitmproxy/tools/console/keymap.py index a42225cfb..0a1c64ef4 100644 --- a/mitmproxy/tools/console/keymap.py +++ b/mitmproxy/tools/console/keymap.py @@ -18,6 +18,7 @@ class KeyBindingError(Exception): Contexts = { "chooser", "commands", + "commonkey", "dataviewer", "eventlog", "flowlist", From 54145360a3bc296ddea4b83711f3b14f45f1188d Mon Sep 17 00:00:00 2001 From: root Date: Sat, 11 Apr 2020 12:02:40 +0530 Subject: [PATCH 2/3] space issue --- mitmproxy/tools/console/defaultkeys.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mitmproxy/tools/console/defaultkeys.py b/mitmproxy/tools/console/defaultkeys.py index 8954a492d..8ed56361f 100644 --- a/mitmproxy/tools/console/defaultkeys.py +++ b/mitmproxy/tools/console/defaultkeys.py @@ -1,14 +1,14 @@ def map(km): km.add(":", "console.command ", ["commonkey", "global"], "Command prompt") - km.add("?", "console.view.help", ["commonkey","global"], "View help") + km.add("?", "console.view.help", ["commonkey", "global"], "View help") km.add("B", "browser.start", ["global"], "Start an attached browser") km.add("C", "console.view.commands", ["global"], "View commands") km.add("K", "console.view.keybindings", ["global"], "View key bindings") km.add("O", "console.view.options", ["commonkey", "global"], "View options") km.add("E", "console.view.eventlog", ["commonkey", "global"], "View event log") km.add("Q", "console.exit", ["commonkey", "global"], "Exit immediately") - km.add("q", "console.view.pop", ["commonkey", "global"], "Exit the current views") + km.add("q", "console.view.pop", ["commonkey", "global"], "Exit the current view") km.add("-", "console.layout.cycle", ["global"], "Cycle to next layout") km.add("shift tab", "console.panes.next", ["global"], "Focus next layout pane") km.add("ctrl right", "console.panes.next", ["global"], "Focus next layout pane") From b6954db601a159af01ac9d7bceace966abe2f89e Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sat, 11 Apr 2020 13:43:56 +0200 Subject: [PATCH 3/3] reduce set of common keys - You've already figured out `?` when you see this, so why mention it. - `Q` isn't that important, pressing `q` multiple times is good enough. --- mitmproxy/tools/console/defaultkeys.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mitmproxy/tools/console/defaultkeys.py b/mitmproxy/tools/console/defaultkeys.py index 8ed56361f..a27fd85ce 100644 --- a/mitmproxy/tools/console/defaultkeys.py +++ b/mitmproxy/tools/console/defaultkeys.py @@ -1,13 +1,13 @@ def map(km): km.add(":", "console.command ", ["commonkey", "global"], "Command prompt") - km.add("?", "console.view.help", ["commonkey", "global"], "View help") + km.add("?", "console.view.help", ["global"], "View help") km.add("B", "browser.start", ["global"], "Start an attached browser") km.add("C", "console.view.commands", ["global"], "View commands") km.add("K", "console.view.keybindings", ["global"], "View key bindings") km.add("O", "console.view.options", ["commonkey", "global"], "View options") km.add("E", "console.view.eventlog", ["commonkey", "global"], "View event log") - km.add("Q", "console.exit", ["commonkey", "global"], "Exit immediately") + km.add("Q", "console.exit", ["global"], "Exit immediately") km.add("q", "console.view.pop", ["commonkey", "global"], "Exit the current view") km.add("-", "console.layout.cycle", ["global"], "Cycle to next layout") km.add("shift tab", "console.panes.next", ["global"], "Focus next layout pane")