aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/console/flowlist.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-04-07 15:59:38 +1200
committerAldo Cortesi <aldo@nullcube.com>2015-04-07 15:59:38 +1200
commite76467e977c061d92f88500b23f11bbf3cc365bb (patch)
tree9722ad8700db8a5726a840779efbbf4d40ee3537 /libmproxy/console/flowlist.py
parentc7b1234e13bd81891d4dc0fcc68de6237cec2e8c (diff)
downloadmitmproxy-e76467e977c061d92f88500b23f11bbf3cc365bb.tar.gz
mitmproxy-e76467e977c061d92f88500b23f11bbf3cc365bb.tar.bz2
mitmproxy-e76467e977c061d92f88500b23f11bbf3cc365bb.zip
Refactor flow list state management
- Use signal mechanism for state synchronisation - Move "Copy to clipboard" shortcut to "P"
Diffstat (limited to 'libmproxy/console/flowlist.py')
-rw-r--r--libmproxy/console/flowlist.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/libmproxy/console/flowlist.py b/libmproxy/console/flowlist.py
index 946bd97b..8923fd60 100644
--- a/libmproxy/console/flowlist.py
+++ b/libmproxy/console/flowlist.py
@@ -15,10 +15,10 @@ def _mkhelp():
("D", "duplicate flow"),
("e", "toggle eventlog"),
("F", "toggle follow flow list"),
- ("g", "copy flow to clipboard"),
("l", "set limit filter pattern"),
("L", "load saved flows"),
("n", "create a new request"),
+ ("P", "copy flow to clipboard"),
("r", "replay request"),
("V", "revert changes to request"),
("w", "save flows "),
@@ -157,11 +157,11 @@ class ConnectionItem(urwid.WidgetWrap):
key = common.shortcuts(key)
if key == "a":
self.flow.accept_intercept(self.master)
- self.master.sync_list_view()
+ signals.flowlist_change.send(self)
elif key == "d":
self.flow.kill(self.master)
self.state.delete_flow(self.flow)
- self.master.sync_list_view()
+ signals.flowlist_change.send(self)
elif key == "D":
f = self.master.duplicate_flow(self.flow)
self.master.view_flow(f)
@@ -169,7 +169,7 @@ class ConnectionItem(urwid.WidgetWrap):
r = self.master.replay_request(self.flow)
if r:
signals.status_message.send(message=r)
- self.master.sync_list_view()
+ signals.flowlist_change.send(self)
elif key == "S":
if not self.master.server_playback:
signals.status_prompt_onekey.send(
@@ -195,7 +195,7 @@ class ConnectionItem(urwid.WidgetWrap):
signals.status_message.send(message="Flow not modified.")
return
self.state.revert(self.flow)
- self.master.sync_list_view()
+ signals.flowlist_change.send(self)
signals.status_message.send(message="Reverted.")
elif key == "w":
signals.status_prompt_onekey.send(
@@ -218,7 +218,7 @@ class ConnectionItem(urwid.WidgetWrap):
callback = self.master.run_script_once,
args = (self.flow,)
)
- elif key == "g":
+ elif key == "P":
common.ask_copy_part("a", self.flow, self.master, self.state)
elif key == "b":
common.ask_save_body(None, self.master, self.state, self.flow)
@@ -231,6 +231,10 @@ class FlowListWalker(urwid.ListWalker):
self.master, self.state = master, state
if self.state.flow_count():
self.set_focus(0)
+ signals.flowlist_change.connect(self.sig_flowlist_change)
+
+ def sig_flowlist_change(self, sender):
+ self._modified()
def get_focus(self):
f, i = self.state.get_focus()
@@ -255,7 +259,10 @@ class FlowListWalker(urwid.ListWalker):
class FlowListBox(urwid.ListBox):
def __init__(self, master):
self.master = master
- urwid.ListBox.__init__(self, master.flow_list_walker)
+ urwid.ListBox.__init__(
+ self,
+ FlowListWalker(master, master.state)
+ )
def get_method_raw(self, k):
if k:
@@ -297,7 +304,7 @@ class FlowListBox(urwid.ListBox):
key = common.shortcuts(key)
if key == "A":
self.master.accept_all()
- self.master.sync_list_view()
+ signals.flowlist_change.send(self)
elif key == "C":
self.master.clear_flows()
elif key == "e":