mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 10:16:27 +00:00
Use last path specified as default prompt.
This commit is contained in:
parent
405e60215c
commit
df9d8832fb
@ -495,11 +495,12 @@ class ConnectionView(WWrap):
|
|||||||
elif key == " ":
|
elif key == " ":
|
||||||
self.master.view_next_flow(self.flow)
|
self.master.view_next_flow(self.flow)
|
||||||
elif key == "|":
|
elif key == "|":
|
||||||
self.master.path_prompt("Script: ", self.run_script)
|
self.master.path_prompt("Script: ", self.state.last_script, self.run_script)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
def run_script(self, path):
|
def run_script(self, path):
|
||||||
path = os.path.expanduser(path)
|
path = os.path.expanduser(path)
|
||||||
|
self.state.last_script = path
|
||||||
try:
|
try:
|
||||||
newflow, serr = self.flow.run_script(path)
|
newflow, serr = self.flow.run_script(path)
|
||||||
except flow.RunException, e:
|
except flow.RunException, e:
|
||||||
@ -583,8 +584,8 @@ class ActionBar(WWrap):
|
|||||||
def selectable(self):
|
def selectable(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def path_prompt(self, prompt):
|
def path_prompt(self, prompt, text):
|
||||||
self.w = PathEdit(prompt)
|
self.w = PathEdit(prompt, text)
|
||||||
|
|
||||||
def prompt(self, prompt):
|
def prompt(self, prompt):
|
||||||
self.w = urwid.Edit(prompt)
|
self.w = urwid.Edit(prompt)
|
||||||
@ -626,8 +627,8 @@ class StatusBar(WWrap):
|
|||||||
def get_edit_text(self):
|
def get_edit_text(self):
|
||||||
return self.ab.w.get_edit_text()
|
return self.ab.w.get_edit_text()
|
||||||
|
|
||||||
def path_prompt(self, prompt):
|
def path_prompt(self, prompt, text):
|
||||||
return self.ab.path_prompt(prompt)
|
return self.ab.path_prompt(prompt, text)
|
||||||
|
|
||||||
def prompt(self, prompt):
|
def prompt(self, prompt):
|
||||||
return self.ab.prompt(prompt)
|
return self.ab.prompt(prompt)
|
||||||
@ -651,6 +652,9 @@ class ConsoleState(flow.State):
|
|||||||
self.view_body_mode = VIEW_BODY_RAW
|
self.view_body_mode = VIEW_BODY_RAW
|
||||||
self.view_flow_mode = VIEW_FLOW_REQUEST
|
self.view_flow_mode = VIEW_FLOW_REQUEST
|
||||||
|
|
||||||
|
self.last_script = ""
|
||||||
|
self.last_saveload = ""
|
||||||
|
|
||||||
def add_browserconnect(self, f):
|
def add_browserconnect(self, f):
|
||||||
flow.State.add_browserconnect(self, f)
|
flow.State.add_browserconnect(self, f)
|
||||||
if self.focus is None:
|
if self.focus is None:
|
||||||
@ -900,12 +904,14 @@ class ConsoleMaster(controller.Master):
|
|||||||
return self._write_flows(path, data)
|
return self._write_flows(path, data)
|
||||||
|
|
||||||
def save_flows(self, path):
|
def save_flows(self, path):
|
||||||
|
self.state.last_saveload = path
|
||||||
data = self.state.dump_flows()
|
data = self.state.dump_flows()
|
||||||
return self._write_flows(path, data)
|
return self._write_flows(path, data)
|
||||||
|
|
||||||
def load_flows(self, path):
|
def load_flows(self, path):
|
||||||
if not path:
|
if not path:
|
||||||
return
|
return
|
||||||
|
self.state.last_saveload = path
|
||||||
path = os.path.expanduser(path)
|
path = os.path.expanduser(path)
|
||||||
try:
|
try:
|
||||||
f = file(path, "r")
|
f = file(path, "r")
|
||||||
@ -1008,8 +1014,8 @@ class ConsoleMaster(controller.Master):
|
|||||||
text.extend(format_keyvals(examples, key="key", val="text", indent=4))
|
text.extend(format_keyvals(examples, key="key", val="text", indent=4))
|
||||||
return urwid.ListBox([urwid.Text(text)])
|
return urwid.ListBox([urwid.Text(text)])
|
||||||
|
|
||||||
def path_prompt(self, prompt, callback, *args):
|
def path_prompt(self, prompt, text, callback, *args):
|
||||||
self.statusbar.path_prompt(prompt)
|
self.statusbar.path_prompt(prompt, text)
|
||||||
self.view.set_focus("footer")
|
self.view.set_focus("footer")
|
||||||
self.prompting = (callback, args)
|
self.prompting = (callback, args)
|
||||||
|
|
||||||
@ -1164,10 +1170,18 @@ class ConsoleMaster(controller.Master):
|
|||||||
)
|
)
|
||||||
k = None
|
k = None
|
||||||
elif k == "S":
|
elif k == "S":
|
||||||
self.path_prompt("Save flows: ", self.save_flows)
|
self.path_prompt(
|
||||||
|
"Save flows: ",
|
||||||
|
self.state.last_saveload,
|
||||||
|
self.save_flows
|
||||||
|
)
|
||||||
k = None
|
k = None
|
||||||
elif k == "L":
|
elif k == "L":
|
||||||
self.path_prompt("Load flows: ", self.load_flows)
|
self.path_prompt(
|
||||||
|
"Load flows: ",
|
||||||
|
self.state.last_saveload,
|
||||||
|
self.load_flows
|
||||||
|
)
|
||||||
k = None
|
k = None
|
||||||
elif k == "c":
|
elif k == "c":
|
||||||
self.prompt("Sticky cookie: ", self.set_stickycookie)
|
self.prompt("Sticky cookie: ", self.set_stickycookie)
|
||||||
|
Loading…
Reference in New Issue
Block a user