Add duplicate to connection view, and rename to "D".

This commit is contained in:
Aldo Cortesi 2012-02-19 00:32:20 +13:00
parent d32d6bc5e3
commit 0434988ade
3 changed files with 12 additions and 7 deletions

View File

@ -516,9 +516,7 @@ class ConsoleMaster(flow.FlowMaster):
def focus_current(self): def focus_current(self):
if self.currentflow: if self.currentflow:
try: try:
ids = [id(i) for i in self.state.view] self.conn_list_view.set_focus(self.state.index(self.currentflow))
idx = ids.index(id(self.currentflow))
self.conn_list_view.set_focus(idx)
except (IndexError, ValueError): except (IndexError, ValueError):
pass pass

View File

@ -8,10 +8,10 @@ def _mkhelp():
("a", "accept this intercepted connection"), ("a", "accept this intercepted connection"),
("C", "clear connection list or eventlog"), ("C", "clear connection list or eventlog"),
("d", "delete flow"), ("d", "delete flow"),
("D", "duplicate flow"),
("e", "toggle eventlog"), ("e", "toggle eventlog"),
("l", "set limit filter pattern"), ("l", "set limit filter pattern"),
("L", "load saved flows"), ("L", "load saved flows"),
("p", "duplicate flow"),
("r", "replay request"), ("r", "replay request"),
("R", "revert changes to request"), ("R", "revert changes to request"),
("w", "save all flows matching current limit"), ("w", "save all flows matching current limit"),
@ -102,6 +102,10 @@ class ConnectionItem(common.WWrap):
self.flow.kill(self.master) self.flow.kill(self.master)
self.state.delete_flow(self.flow) self.state.delete_flow(self.flow)
self.master.sync_list_view() self.master.sync_list_view()
elif key == "D":
f = self.master.duplicate_flow(self.flow)
self.master.currentflow = f
self.master.focus_current()
elif key == "l": elif key == "l":
self.master.prompt("Limit: ", self.state.limit_txt, self.master.set_limit) self.master.prompt("Limit: ", self.state.limit_txt, self.master.set_limit)
self.master.sync_list_view() self.master.sync_list_view()
@ -111,9 +115,6 @@ class ConnectionItem(common.WWrap):
self.state.last_saveload, self.state.last_saveload,
self.master.load_flows_callback self.master.load_flows_callback
) )
elif key == "p":
f = self.master.duplicate_flow(self.flow)
self.master.conn_list_view.set_focus(self.state.index(f))
elif key == "r": elif key == "r":
r = self.master.replay_request(self.flow) r = self.master.replay_request(self.flow)
if r: if r:

View File

@ -10,6 +10,7 @@ def _mkhelp():
("a", "accept this intercepted connection"), ("a", "accept this intercepted connection"),
("b", "save request/response body"), ("b", "save request/response body"),
("d", "delete flow"), ("d", "delete flow"),
("D", "duplicate flow"),
("e", "edit request/response"), ("e", "edit request/response"),
("m", "change body display mode"), ("m", "change body display mode"),
(None, (None,
@ -463,6 +464,11 @@ class ConnectionView(common.WWrap):
f = self.flow f = self.flow
f.kill(self.master) f.kill(self.master)
self.state.delete_flow(f) self.state.delete_flow(f)
elif key == "D":
f = self.master.duplicate_flow(self.flow)
self.master.view_flow(f)
self.master.currentflow = f
self.master.statusbar.message("Duplicated.")
elif key == "e": elif key == "e":
if self.state.view_flow_mode == common.VIEW_FLOW_REQUEST: if self.state.view_flow_mode == common.VIEW_FLOW_REQUEST:
self.master.prompt_onekey( self.master.prompt_onekey(