mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
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:
parent
15cc09f1b8
commit
2df2fe0e4c
@ -154,6 +154,10 @@ class StatusBar(common.WWrap):
|
||||
r.append("[")
|
||||
r.append(("heading_key", "P"))
|
||||
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 = []
|
||||
if self.master.anticache:
|
||||
@ -677,6 +681,12 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
def set_intercept(self, 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):
|
||||
if not txt:
|
||||
self.server.config.reverse_proxy = None
|
||||
@ -769,6 +779,12 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
),
|
||||
self.quit,
|
||||
)
|
||||
elif k == "M":
|
||||
self.prompt_onekey(
|
||||
"Global default display mode",
|
||||
contentview.VIEW_PROMPT,
|
||||
self.change_default_display_mode
|
||||
)
|
||||
elif k == "P":
|
||||
if self.server.config.reverse_proxy:
|
||||
p = utils.unparse_url(*self.server.config.reverse_proxy)
|
||||
|
@ -30,12 +30,26 @@ VIEW_NAMES = {
|
||||
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 = {
|
||||
"a": VIEW_AUTO,
|
||||
"i": VIEW_IMAGE,
|
||||
"j": VIEW_JAVASCRIPT,
|
||||
"s": VIEW_JSON,
|
||||
"u": VIEW_URLENCODED,
|
||||
"m": VIEW_MULTIPART,
|
||||
"x": VIEW_XML,
|
||||
"r": VIEW_RAW,
|
||||
"h": VIEW_HEX,
|
||||
|
@ -378,11 +378,6 @@ class FlowView(common.WWrap):
|
||||
)
|
||||
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):
|
||||
if key == " ":
|
||||
self.view_next_flow(self.flow)
|
||||
@ -455,35 +450,10 @@ class FlowView(common.WWrap):
|
||||
elif key == "m":
|
||||
self.master.prompt_onekey(
|
||||
"Display mode",
|
||||
(
|
||||
("auto detect", "a"),
|
||||
("hex", "h"),
|
||||
("image", "i"),
|
||||
("javascript", "j"),
|
||||
("json", "s"),
|
||||
("raw", "r"),
|
||||
("urlencoded", "u"),
|
||||
("xmlish", "x"),
|
||||
),
|
||||
contentview.VIEW_PROMPT,
|
||||
self.change_this_display_mode
|
||||
)
|
||||
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":
|
||||
self.view_prev_flow(self.flow)
|
||||
elif key == "r":
|
||||
|
@ -62,6 +62,39 @@ class HelpView(urwid.ListBox):
|
||||
keys = [
|
||||
("c", "client replay"),
|
||||
("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:"),
|
||||
(None,
|
||||
|
Loading…
Reference in New Issue
Block a user