implement a toggle for viewing marked flows only in console

This commit is contained in:
Christian Frichot 2016-05-24 07:14:05 -07:00
parent ebaad91484
commit dbc3e72723
3 changed files with 44 additions and 0 deletions

View File

@ -33,6 +33,8 @@ class ConsoleState(flow.State):
self.default_body_view = contentviews.get("Auto")
self.flowsettings = weakref.WeakKeyDictionary()
self.last_search = None
self.last_filter = None
self.mark_filter = False
def __setattr__(self, name, value):
self.__dict__[name] = value
@ -106,6 +108,37 @@ class ConsoleState(flow.State):
self.set_focus(self.focus)
return ret
def filter_marked(self, m):
def actual_func(x):
if x.id in m:
return True
return False
return actual_func
def enable_marked_filter(self):
self.last_filter = self.limit_txt
marked_flows = []
for f in self.flows:
if self.flow_marked(f):
marked_flows.append(f.id)
if len(marked_flows) > 0:
f = self.filter_marked(marked_flows)
self.view._close()
self.view = flow.FlowView(self.flows, f)
self.focus = 0
self.set_focus(self.focus)
self.mark_filter = True
def disable_marked_filter(self):
if self.last_filter is None:
self.view = flow.FlowView(self.flows, None)
else:
self.set_limit(self.last_filter)
self.focus = 0
self.set_focus(self.focus)
self.last_filter = None
self.mark_filter = False
def clear(self):
marked_flows = []
for f in self.flows:

View File

@ -21,6 +21,7 @@ def _mkhelp():
("l", "set limit filter pattern"),
("L", "load saved flows"),
("m", "toggle flow mark"),
("M", "toggle marked flow view"),
("n", "create a new request"),
("P", "copy flow to clipboard"),
("r", "replay request"),
@ -197,6 +198,12 @@ class ConnectionItem(urwid.WidgetWrap):
else:
self.state.set_flow_marked(self.flow, True)
signals.flowlist_change.send(self)
elif key == "M":
if self.state.mark_filter:
self.state.disable_marked_filter()
else:
self.state.enable_marked_filter()
signals.flowlist_change.send(self)
elif key == "r":
r = self.master.replay_request(self.flow)
if r:

View File

@ -163,6 +163,10 @@ class StatusBar(urwid.WidgetWrap):
r.append("[")
r.append(("heading_key", "l"))
r.append(":%s]" % self.master.state.limit_txt)
if self.master.state.mark_filter:
r.append("[")
r.append(("heading_key", "Marked Flows"))
r.append("]")
if self.master.stickycookie_txt:
r.append("[")
r.append(("heading_key", "t"))