From 1619d164ffc4c82da80f00598f3358fe8ca64313 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 31 Jan 2011 10:57:33 +1300 Subject: [PATCH] Re-jigger flow view shortcuts so we don't over-ride global shortcuts. --- libmproxy/console.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/libmproxy/console.py b/libmproxy/console.py index 5afe64b39..4c51e786b 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -358,6 +358,15 @@ class ConnectionView(WWrap): key = None self.master.refresh_connection(self.flow) + def _changeview(self, v): + if v == "r": + self.state.view_body_mode = VIEW_BODY_RAW + elif v == "h": + self.state.view_body_mode = VIEW_BODY_BINARY + elif v == "i": + self.state.view_body_mode = VIEW_BODY_INDENT + self.master.refresh_connection(self.flow) + def keypress(self, size, key): if key == "tab": if self.state.view_flow_mode == VIEW_FLOW_REQUEST: @@ -373,15 +382,17 @@ class ConnectionView(WWrap): elif key == "A": self.master.accept_all() self.master.view_flow(self.flow) - elif key == "b": - self.state.view_body_mode = VIEW_BODY_BINARY - self.master.refresh_connection(self.flow) - elif key == "r": - self.state.view_body_mode = VIEW_BODY_RAW - self.master.refresh_connection(self.flow) - elif key == "I": - self.state.view_body_mode = VIEW_BODY_INDENT - self.master.refresh_connection(self.flow) + elif key == "m": + self.master.prompt_onekey( + "View", + ( + ("raw", "r"), + ("indent", "i"), + ("hex", "h"), + ), + self._changeview + ) + key = None elif key == "e": if self.state.view_flow_mode == VIEW_FLOW_REQUEST: self.master.prompt_onekey( @@ -931,18 +942,14 @@ class ConsoleMaster(controller.Master): text.extend([("head", "\n\nConnection view keys:\n")]) keys = [ - ("b", "view hexdump"), - ("r", "view raw"), - ("I", "view indented"), - None, - ("space", "next flow"), - ("p", "previous flow"), - None, ("e", "edit response/request"), + ("m", "change view mode (raw, indent, hex)"), + ("p", "previous flow"), ("s", "save this flow"), ("v", "view contents in external viewer"), ("w", "save request or response body"), ("tab", "toggle response/request view"), + ("space", "next flow"), ] text.extend(format_keyvals(keys, key="key", val="text", indent=4))