Move "M" shortcut key to global scope.

You now don't have to be viewing a flow to change global default view.
This commit is contained in:
Aldo Cortesi 2012-04-02 10:49:57 +12:00
parent 15cc09f1b8
commit 2df2fe0e4c
4 changed files with 64 additions and 31 deletions

View File

@ -154,6 +154,10 @@ class StatusBar(common.WWrap):
r.append("[") r.append("[")
r.append(("heading_key", "P")) r.append(("heading_key", "P"))
r.append(":%s]"%utils.unparse_url(*self.master.server.config.reverse_proxy)) r.append(":%s]"%utils.unparse_url(*self.master.server.config.reverse_proxy))
if self.master.state.default_body_view != contentview.VIEW_AUTO:
r.append("[")
r.append(("heading_key", "M"))
r.append(":%s]"%contentview.VIEW_NAMES[self.master.state.default_body_view])
opts = [] opts = []
if self.master.anticache: if self.master.anticache:
@ -677,6 +681,12 @@ class ConsoleMaster(flow.FlowMaster):
def set_intercept(self, txt): def set_intercept(self, txt):
return self.state.set_intercept(txt) return self.state.set_intercept(txt)
def change_default_display_mode(self, t):
v = contentview.VIEW_SHORTCUTS.get(t)
self.state.default_body_view = v
if self.currentflow:
self.refresh_flow(self.currentflow)
def set_reverse_proxy(self, txt): def set_reverse_proxy(self, txt):
if not txt: if not txt:
self.server.config.reverse_proxy = None self.server.config.reverse_proxy = None
@ -769,6 +779,12 @@ class ConsoleMaster(flow.FlowMaster):
), ),
self.quit, self.quit,
) )
elif k == "M":
self.prompt_onekey(
"Global default display mode",
contentview.VIEW_PROMPT,
self.change_default_display_mode
)
elif k == "P": elif k == "P":
if self.server.config.reverse_proxy: if self.server.config.reverse_proxy:
p = utils.unparse_url(*self.server.config.reverse_proxy) p = utils.unparse_url(*self.server.config.reverse_proxy)

View File

@ -30,12 +30,26 @@ VIEW_NAMES = {
VIEW_HEX: "Hex", VIEW_HEX: "Hex",
} }
VIEW_PROMPT = (
("auto detect", "a"),
("hex", "h"),
("image", "i"),
("javascript", "j"),
("json", "s"),
("raw", "r"),
("multipart", "m"),
("urlencoded", "u"),
("xmlish", "x"),
)
VIEW_SHORTCUTS = { VIEW_SHORTCUTS = {
"a": VIEW_AUTO, "a": VIEW_AUTO,
"i": VIEW_IMAGE, "i": VIEW_IMAGE,
"j": VIEW_JAVASCRIPT, "j": VIEW_JAVASCRIPT,
"s": VIEW_JSON, "s": VIEW_JSON,
"u": VIEW_URLENCODED, "u": VIEW_URLENCODED,
"m": VIEW_MULTIPART,
"x": VIEW_XML, "x": VIEW_XML,
"r": VIEW_RAW, "r": VIEW_RAW,
"h": VIEW_HEX, "h": VIEW_HEX,

View File

@ -378,11 +378,6 @@ class FlowView(common.WWrap):
) )
self.master.refresh_flow(self.flow) self.master.refresh_flow(self.flow)
def change_default_display_mode(self, t):
v = contentview.VIEW_SHORTCUTS.get(t)
self.state.default_body_view = v
self.master.refresh_flow(self.flow)
def keypress(self, size, key): def keypress(self, size, key):
if key == " ": if key == " ":
self.view_next_flow(self.flow) self.view_next_flow(self.flow)
@ -455,35 +450,10 @@ class FlowView(common.WWrap):
elif key == "m": elif key == "m":
self.master.prompt_onekey( self.master.prompt_onekey(
"Display mode", "Display mode",
( contentview.VIEW_PROMPT,
("auto detect", "a"),
("hex", "h"),
("image", "i"),
("javascript", "j"),
("json", "s"),
("raw", "r"),
("urlencoded", "u"),
("xmlish", "x"),
),
self.change_this_display_mode self.change_this_display_mode
) )
key = None key = None
elif key == "M":
self.master.prompt_onekey(
"Global default display mode",
(
("auto detect", "a"),
("hex", "h"),
("image", "i"),
("javascript", "j"),
("json", "s"),
("raw", "r"),
("urlencoded", "u"),
("xmlish", "x"),
),
self.change_default_display_mode
)
key = None
elif key == "p": elif key == "p":
self.view_prev_flow(self.flow) self.view_prev_flow(self.flow)
elif key == "r": elif key == "r":

View File

@ -62,6 +62,39 @@ class HelpView(urwid.ListBox):
keys = [ keys = [
("c", "client replay"), ("c", "client replay"),
("i", "set interception pattern"), ("i", "set interception pattern"),
("M", "change global default display mode"),
(None,
common.highlight_key("automatic", "a") +
[("text", ": automatic detection")]
),
(None,
common.highlight_key("hex", "h") +
[("text", ": Hex")]
),
(None,
common.highlight_key("image", "i") +
[("text", ": Image")]
),
(None,
common.highlight_key("javascript", "j") +
[("text", ": JavaScript")]
),
(None,
common.highlight_key("json", "s") +
[("text", ": JSON")]
),
(None,
common.highlight_key("urlencoded", "u") +
[("text", ": URL-encoded data")]
),
(None,
common.highlight_key("raw", "r") +
[("text", ": raw data")]
),
(None,
common.highlight_key("xml", "x") +
[("text", ": XML")]
),
("o", "toggle options:"), ("o", "toggle options:"),
(None, (None,