2015-03-20 00:26:08 +00:00
|
|
|
import urwid
|
2015-03-31 20:25:50 +00:00
|
|
|
from . import grideditor, signals, contentview
|
|
|
|
|
2015-03-20 00:26:08 +00:00
|
|
|
|
|
|
|
class Window(urwid.Frame):
|
2015-03-31 20:25:50 +00:00
|
|
|
def __init__(self, master, body, header, footer, helpctx):
|
2015-03-20 00:26:08 +00:00
|
|
|
urwid.Frame.__init__(self, body, header=header, footer=footer)
|
|
|
|
self.master = master
|
2015-03-31 20:25:50 +00:00
|
|
|
self.helpctx = helpctx
|
2015-03-22 00:32:24 +00:00
|
|
|
signals.focus.connect(self.sig_focus)
|
|
|
|
|
|
|
|
def sig_focus(self, sender, section):
|
|
|
|
self.focus_position = section
|
2015-03-20 00:26:08 +00:00
|
|
|
|
|
|
|
def keypress(self, size, k):
|
2015-03-31 20:25:50 +00:00
|
|
|
k = super(self.__class__, self).keypress(size, k)
|
2015-03-22 00:32:24 +00:00
|
|
|
if k == "?":
|
2015-03-31 20:25:50 +00:00
|
|
|
self.master.view_help(self.helpctx)
|
2015-03-22 00:32:24 +00:00
|
|
|
elif k == "c":
|
|
|
|
if not self.master.client_playback:
|
2015-03-22 00:59:34 +00:00
|
|
|
signals.status_prompt_path.send(
|
2015-03-22 00:32:24 +00:00
|
|
|
self,
|
2015-03-22 00:59:34 +00:00
|
|
|
prompt = "Client replay",
|
2015-03-22 00:32:24 +00:00
|
|
|
callback = self.master.client_playback_path
|
2015-03-20 00:26:08 +00:00
|
|
|
)
|
2015-03-22 00:32:24 +00:00
|
|
|
else:
|
|
|
|
signals.status_prompt_onekey.send(
|
|
|
|
self,
|
|
|
|
prompt = "Stop current client replay?",
|
|
|
|
keys = (
|
2015-03-20 00:26:08 +00:00
|
|
|
("yes", "y"),
|
|
|
|
("no", "n"),
|
|
|
|
),
|
2015-03-22 00:32:24 +00:00
|
|
|
callback = self.master.stop_client_playback_prompt,
|
2015-03-20 00:26:08 +00:00
|
|
|
)
|
2015-03-22 00:32:24 +00:00
|
|
|
elif k == "T":
|
|
|
|
self.master.view_grideditor(
|
|
|
|
grideditor.HostPatternEditor(
|
|
|
|
self.master,
|
|
|
|
[[x] for x in self.master.get_tcp_filter()],
|
|
|
|
self.master.edit_tcp_filter
|
2015-03-20 00:26:08 +00:00
|
|
|
)
|
2015-03-22 00:32:24 +00:00
|
|
|
)
|
|
|
|
elif k == "i":
|
|
|
|
signals.status_prompt.send(
|
|
|
|
self,
|
2015-03-22 00:59:34 +00:00
|
|
|
prompt = "Intercept filter",
|
2015-03-22 00:32:24 +00:00
|
|
|
text = self.master.state.intercept_txt,
|
|
|
|
callback = self.master.set_intercept
|
|
|
|
)
|
2015-04-03 01:10:57 +00:00
|
|
|
elif k == "o":
|
|
|
|
self.master.view_options()
|
2015-03-22 00:32:24 +00:00
|
|
|
elif k == "Q":
|
|
|
|
raise urwid.ExitMainLoop
|
|
|
|
elif k == "q":
|
2015-03-31 20:25:50 +00:00
|
|
|
signals.pop_view_state.send(self)
|
2015-03-22 00:32:24 +00:00
|
|
|
elif k == "M":
|
|
|
|
signals.status_prompt_onekey.send(
|
|
|
|
prompt = "Global default display mode",
|
|
|
|
keys = contentview.view_prompts,
|
|
|
|
callback = self.master.change_default_display_mode
|
|
|
|
)
|
|
|
|
elif k == "R":
|
|
|
|
self.master.view_grideditor(
|
|
|
|
grideditor.ReplaceEditor(
|
|
|
|
self.master,
|
|
|
|
self.master.replacehooks.get_specs(),
|
|
|
|
self.master.replacehooks.set
|
2015-03-20 00:26:08 +00:00
|
|
|
)
|
2015-03-22 00:32:24 +00:00
|
|
|
)
|
|
|
|
elif k == "s":
|
|
|
|
self.master.view_grideditor(
|
|
|
|
grideditor.ScriptEditor(
|
|
|
|
self.master,
|
|
|
|
[[i.command] for i in self.master.scripts],
|
|
|
|
self.master.edit_scripts
|
2015-03-20 00:26:08 +00:00
|
|
|
)
|
2015-03-22 00:32:24 +00:00
|
|
|
)
|
|
|
|
elif k == "S":
|
|
|
|
if not self.master.server_playback:
|
2015-03-22 00:59:34 +00:00
|
|
|
signals.status_prompt_path.send(
|
2015-03-22 00:32:24 +00:00
|
|
|
self,
|
2015-03-22 00:59:34 +00:00
|
|
|
prompt = "Server replay path",
|
2015-03-22 00:32:24 +00:00
|
|
|
callback = self.master.server_playback_path
|
2015-03-20 00:26:08 +00:00
|
|
|
)
|
|
|
|
else:
|
2015-03-22 00:32:24 +00:00
|
|
|
signals.status_prompt_onekey.send(
|
|
|
|
self,
|
|
|
|
prompt = "Stop current server replay?",
|
|
|
|
keys = (
|
|
|
|
("yes", "y"),
|
|
|
|
("no", "n"),
|
|
|
|
),
|
|
|
|
callback = self.master.stop_server_playback_prompt,
|
|
|
|
)
|
|
|
|
elif k == "t":
|
|
|
|
signals.status_prompt.send(
|
2015-03-22 00:59:34 +00:00
|
|
|
prompt = "Sticky cookie filter",
|
2015-03-22 00:32:24 +00:00
|
|
|
text = self.master.stickycookie_txt,
|
|
|
|
callback = self.master.set_stickycookie
|
|
|
|
)
|
|
|
|
elif k == "u":
|
|
|
|
signals.status_prompt.send(
|
2015-03-22 00:59:34 +00:00
|
|
|
prompt = "Sticky auth filter",
|
2015-03-22 00:32:24 +00:00
|
|
|
text = self.master.stickyauth_txt,
|
|
|
|
callback = self.master.set_stickyauth
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
return k
|