mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 11:19:23 +00:00
console: more consistent view stack management
This commit is contained in:
parent
e963a9da48
commit
d20069fcd2
@ -231,8 +231,9 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.loop.set_alarm_in(seconds, cb)
|
self.loop.set_alarm_in(seconds, cb)
|
||||||
|
|
||||||
def sig_pop_view_state(self, sender):
|
def sig_pop_view_state(self, sender):
|
||||||
if self.view_stack:
|
if len(self.view_stack) > 1:
|
||||||
self.loop.widget = self.view_stack.pop()
|
self.view_stack.pop()
|
||||||
|
self.loop.widget = self.view_stack[-1]
|
||||||
else:
|
else:
|
||||||
signals.status_prompt_onekey.send(
|
signals.status_prompt_onekey.send(
|
||||||
self,
|
self,
|
||||||
@ -244,8 +245,10 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
callback = self.quit,
|
callback = self.quit,
|
||||||
)
|
)
|
||||||
|
|
||||||
def sig_push_view_state(self, sender):
|
def sig_push_view_state(self, sender, window):
|
||||||
self.view_stack.append(self.loop.widget)
|
self.view_stack.append(window)
|
||||||
|
self.loop.widget = window
|
||||||
|
self.loop.draw_screen()
|
||||||
|
|
||||||
def start_stream_to_path(self, path, mode="wb"):
|
def start_stream_to_path(self, path, mode="wb"):
|
||||||
path = os.path.expanduser(path)
|
path = os.path.expanduser(path)
|
||||||
@ -463,47 +466,55 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
def view_help(self, helpctx):
|
def view_help(self, helpctx):
|
||||||
signals.push_view_state.send(self)
|
signals.push_view_state.send(
|
||||||
self.loop.widget = window.Window(
|
self,
|
||||||
|
window = window.Window(
|
||||||
self,
|
self,
|
||||||
help.HelpView(helpctx),
|
help.HelpView(helpctx),
|
||||||
None,
|
None,
|
||||||
statusbar.StatusBar(self, help.footer),
|
statusbar.StatusBar(self, help.footer),
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def view_options(self):
|
def view_options(self):
|
||||||
for i in self.view_stack:
|
for i in self.view_stack:
|
||||||
if isinstance(i["body"], options.Options):
|
if isinstance(i["body"], options.Options):
|
||||||
return
|
return
|
||||||
signals.push_view_state.send(self)
|
signals.push_view_state.send(
|
||||||
self.loop.widget = window.Window(
|
self,
|
||||||
|
window = window.Window(
|
||||||
self,
|
self,
|
||||||
options.Options(self),
|
options.Options(self),
|
||||||
None,
|
None,
|
||||||
statusbar.StatusBar(self, options.footer),
|
statusbar.StatusBar(self, options.footer),
|
||||||
options.help_context,
|
options.help_context,
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def view_palette_picker(self):
|
def view_palette_picker(self):
|
||||||
signals.push_view_state.send(self)
|
signals.push_view_state.send(
|
||||||
self.loop.widget = window.Window(
|
self,
|
||||||
|
window = window.Window(
|
||||||
self,
|
self,
|
||||||
palettepicker.PalettePicker(self),
|
palettepicker.PalettePicker(self),
|
||||||
None,
|
None,
|
||||||
statusbar.StatusBar(self, palettepicker.footer),
|
statusbar.StatusBar(self, palettepicker.footer),
|
||||||
palettepicker.help_context,
|
palettepicker.help_context,
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def view_grideditor(self, ge):
|
def view_grideditor(self, ge):
|
||||||
signals.push_view_state.send(self)
|
signals.push_view_state.send(
|
||||||
self.loop.widget = window.Window(
|
self,
|
||||||
|
window = window.Window(
|
||||||
self,
|
self,
|
||||||
ge,
|
ge,
|
||||||
None,
|
None,
|
||||||
statusbar.StatusBar(self, grideditor.FOOTER),
|
statusbar.StatusBar(self, grideditor.FOOTER),
|
||||||
ge.make_help()
|
ge.make_help()
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def view_flowlist(self):
|
def view_flowlist(self):
|
||||||
if self.ui.started:
|
if self.ui.started:
|
||||||
@ -516,25 +527,29 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
else:
|
else:
|
||||||
body = flowlist.FlowListBox(self)
|
body = flowlist.FlowListBox(self)
|
||||||
|
|
||||||
self.loop.widget = window.Window(
|
signals.push_view_state.send(
|
||||||
|
self,
|
||||||
|
window = window.Window(
|
||||||
self,
|
self,
|
||||||
body,
|
body,
|
||||||
None,
|
None,
|
||||||
statusbar.StatusBar(self, flowlist.footer),
|
statusbar.StatusBar(self, flowlist.footer),
|
||||||
flowlist.help_context
|
flowlist.help_context
|
||||||
)
|
)
|
||||||
self.loop.draw_screen()
|
)
|
||||||
|
|
||||||
def view_flow(self, flow, tab_offset=0):
|
def view_flow(self, flow, tab_offset=0):
|
||||||
signals.push_view_state.send(self)
|
|
||||||
self.state.set_focus_flow(flow)
|
self.state.set_focus_flow(flow)
|
||||||
self.loop.widget = window.Window(
|
signals.push_view_state.send(
|
||||||
|
self,
|
||||||
|
window = window.Window(
|
||||||
self,
|
self,
|
||||||
flowview.FlowView(self, self.state, flow, tab_offset),
|
flowview.FlowView(self, self.state, flow, tab_offset),
|
||||||
flowview.FlowViewHeader(self, flow),
|
flowview.FlowViewHeader(self, flow),
|
||||||
statusbar.StatusBar(self, flowview.footer),
|
statusbar.StatusBar(self, flowview.footer),
|
||||||
flowview.help_context
|
flowview.help_context
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def _write_flows(self, path, flows):
|
def _write_flows(self, path, flows):
|
||||||
if not path:
|
if not path:
|
||||||
|
Loading…
Reference in New Issue
Block a user