Start consolidating keybindings.

I want each view to have a more coherent set of bindings. This means minimizing
the global bindings, and making some bindings accessible only from screens
related to their functionality.
This commit is contained in:
Aldo Cortesi 2012-02-08 22:28:15 +13:00
parent e3f28e1c06
commit 866a93a8bc
4 changed files with 41 additions and 32 deletions

View File

@ -372,11 +372,13 @@ class ConsoleMaster(flow.FlowMaster):
sys.exit(1)
def run_script_once(self, path, f):
if not path:
return
ret = self.get_script(path)
if ret[0]:
self.statusbar.message(ret[0])
return
s = ret[1]
if f.request:
s.run("request", f)
if f.response:
@ -781,16 +783,6 @@ class ConsoleMaster(flow.FlowMaster):
self.set_intercept
)
self.sync_list_view()
elif k == "m":
self.prompt_onekey(
"View",
(
("raw", "r"),
("pretty", "p"),
("hex", "h"),
),
self.changeview
)
elif k == "Q":
raise Stop
elif k == "q":

View File

@ -4,12 +4,15 @@ import common
def _mkhelp():
text = []
keys = [
("A", "accept all intercepted connections"),
("a", "accept this intercepted connection"),
("C", "clear connection list or eventlog"),
("d", "delete connection from view"),
("v", "toggle eventlog"),
("X", "kill and delete connection, even if it's mid-intercept"),
("tab", "tab between eventlog and connection list"),
("enter", "view connection"),
("|", "run script on this flow"),
]
text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
return text
@ -117,10 +120,13 @@ class ConnectionItem(common.WWrap):
self.master.view_flow(self.flow)
elif key == "|":
self.master.path_prompt(
"Send flow to script: ", self.state.last_script,
self.master.run_script_once, self.flow
"Send flow to script: ",
self.state.last_script,
self.master.run_script_once,
self.flow
)
return key
else:
return key
class ConnectionListView(urwid.ListWalker):

View File

@ -5,13 +5,29 @@ from .. import utils, encoding, flow
def _mkhelp():
text = []
keys = [
("A", "accept all intercepted connections"),
("a", "accept this intercepted connection"),
("b", "save request/response body"),
("e", "edit request/response"),
("m", "change body display mode"),
(None,
common.highlight_key("raw", "r") +
[("text", ": raw data")]
),
(None,
common.highlight_key("pretty", "p") +
[("text", ": pretty-print XML, HTML and JSON")]
),
(None,
common.highlight_key("hex", "h") +
[("text", ": hex dump")]
),
("p", "previous flow"),
("v", "view body in external viewer"),
("z", "encode/decode a request/response"),
("tab", "toggle request/response view"),
("space", "next flow"),
("|", "run script on this flow"),
]
text.extend(common.format_keyvals(keys, key="key", val="text", indent=4))
return text
@ -433,6 +449,17 @@ class ConnectionView(common.WWrap):
self.edit
)
key = None
elif key == "m":
self.master.prompt_onekey(
"View",
(
("raw", "r"),
("pretty", "p"),
("hex", "h"),
),
self.master.changeview
)
key = None
elif key == "p":
self.view_prev_flow(self.flow)
elif key == "r":
@ -490,7 +517,8 @@ class ConnectionView(common.WWrap):
conn
)
self.master.refresh_connection(self.flow)
return key
else:
return key
def encode_callback(self, key, conn):
encoding_map = {

View File

@ -28,28 +28,12 @@ class HelpView(urwid.ListBox):
text.append(("head", "\n\nGlobal keys:\n"))
keys = [
("A", "accept all intercepted connections"),
("a", "accept this intercepted connection"),
("c", "client replay"),
("i", "set interception pattern"),
("j, k", "up, down"),
("l", "set limit filter pattern"),
("L", "load saved flows"),
("m", "change body display mode"),
(None,
common.highlight_key("raw", "r") +
[("text", ": raw data")]
),
(None,
common.highlight_key("pretty", "p") +
[("text", ": pretty-print XML, HTML and JSON")]
),
(None,
common.highlight_key("hex", "h") +
[("text", ": hex dump")]
),
("o", "toggle options:"),
(None,
common.highlight_key("anticache", "a") +
@ -78,7 +62,6 @@ class HelpView(urwid.ListBox):
("u", "set sticky auth expression"),
("w", "save all flows matching current limit"),
("W", "save this flow"),
("|", "run script on this flow"),
("space", "page down"),
("pg up/down", "page up/down"),
]