def keypress(self, size, key): key = common.shortcuts(key) if key == "L": signals.status_prompt_path.send( self, prompt="Load flows", callback=self.master.load_flows_callback) elif key == "M": self.master.view.toggle_marked() elif key == "n": signals.status_prompt_onekey.send(prompt="Method", keys=common.METHOD_OPTIONS, callback=self.get_method) elif key == "o": orders = [(i[1], i[0]) for i in view.orders] lookup = dict([(i[0], i[1]) for i in view.orders]) def change_order(k): self.master.options.console_order = lookup[k] signals.status_prompt_onekey.send(prompt="Order", keys=orders, callback=change_order) else: return urwid.ListBox.keypress(self, size, key)
def keypress(self, size, key): key = common.shortcuts(key) if key == "A": for f in self.master.view: if f.intercepted: f.resume() self.master.view.update(f) elif key == "z": self.master.view.clear() elif key == "e": self.master.toggle_eventlog() elif key == "g": if len(self.master.view): self.master.view.focus.index = 0 elif key == "G": if len(self.master.view): self.master.view.focus.index = len(self.master.view) - 1 elif key == "f": signals.status_prompt.send( prompt="Filter View", text=self.master.options.filter, callback=self.master.options.setter("filter")) elif key == "L": signals.status_prompt_path.send( self, prompt="Load flows", callback=self.master.load_flows_callback) elif key == "M": self.master.view.toggle_marked() elif key == "n": signals.status_prompt_onekey.send(prompt="Method", keys=common.METHOD_OPTIONS, callback=self.get_method) elif key == "o": orders = [(i[1], i[0]) for i in view.orders] lookup = dict([(i[0], i[1]) for i in view.orders]) def change_order(k): self.master.options.order = lookup[k] signals.status_prompt_onekey.send(prompt="Order", keys=orders, callback=change_order) elif key == "F": o = self.master.options o.focus_follow = not o.focus_follow elif key == "v": val = not self.master.options.order_reversed self.master.options.order_reversed = val elif key == "W": if self.master.options.streamfile: self.master.options.streamfile = None else: signals.status_prompt_path.send( self, prompt="Stream flows to", callback=lambda path: self.master.options.update(streamfile =path)) else: return urwid.ListBox.keypress(self, size, key)
def keypress(self, size, key): key = common.shortcuts(key) if key == "z": self.master.clear_events() key = None elif key == "G": self.set_focus(len(self.master.logbuffer) - 1) elif key == "g": self.set_focus(0) return urwid.ListBox.keypress(self, size, key)
def keypress(self, size, key): if key == "enter" or key == " ": self.get_focus()[0].option.activate() return None key = common.shortcuts(key) if key in self.keymap: self.keymap[key].activate() self.set_focus(self.options.index(self.keymap[key])) return None return super().keypress(size, key)
def keypress(self, size, key): key = common.shortcuts(key) if key == "q": signals.pop_view_state.send(self) return None elif key == "?": key = None elif key == "g": self.set_focus(0) elif key == "G": self.set_focus(len(self.body.contents)) return urwid.ListBox.keypress(self, size, key)
def keypress(self, size, key): key = common.shortcuts(key) if key == "z": self.master.clear_events() key = None elif key == "G": self.set_focus(len(self.master.logbuffer) - 1) elif key == "g": self.set_focus(0) elif key == "F": o = self.master.options o.console_focus_follow = not o.console_focus_follow return urwid.ListBox.keypress(self, size, key)
def keypress(self, size, key): key = common.shortcuts(key) if key == "A": for f in self.master.view: if f.intercepted: f.resume() signals.flowlist_change.send(self) elif key == "z": self.master.view.clear() elif key == "e": self.master.toggle_eventlog() elif key == "g": self.master.view.focus.index = 0 elif key == "G": self.master.view.focus.index = len(self.master.view) - 1 elif key == "f": signals.status_prompt.send( prompt="Filter View", text=self.master.options.filter, callback=self.master.options.setter("filter") ) elif key == "L": signals.status_prompt_path.send(self, prompt="Load flows", callback=self.master.load_flows_callback) elif key == "n": signals.status_prompt_onekey.send(prompt="Method", keys=common.METHOD_OPTIONS, callback=self.get_method) elif key == "o": orders = [(i[1], i[0]) for i in view.orders] lookup = dict([(i[0], i[1]) for i in view.orders]) def change_order(k): self.master.options.order = lookup[k] signals.status_prompt_onekey.send(prompt="Order", keys=orders, callback=change_order) elif key == "F": o = self.master.options o.focus_follow = not o.focus_follow elif key == "v": val = not self.master.options.order_reversed self.master.options.order_reversed = val elif key == "W": if self.master.options.outfile: self.master.options.outfile = None else: signals.status_prompt_path.send( self, prompt="Stream flows to", callback=lambda path: self.master.options.update(outfile=(path, "ab")), ) else: return urwid.ListBox.keypress(self, size, key)
def keypress(self, size, key): key = common.shortcuts(key) if key == "tab": self.focus_position = (self.focus_position + 1) % len( self.widget_list) self.widget_list[1].set_active(self.focus_position == 1) key = None # This is essentially a copypasta from urwid.Pile's keypress handler. # So much for "closed for modification, but open for extension". item_rows = None if len(size) == 2: item_rows = self.get_item_rows(size, focus=True) i = self.widget_list.index(self.focus_item) tsize = self.get_item_size(size, i, True, item_rows) return self.focus_item.keypress(tsize, key)
def keypress(self, size, key): key = common.shortcuts(key) if key == "A": self.master.accept_all() signals.flowlist_change.send(self) elif key == "z": self.master.clear_flows() elif key == "e": self.master.toggle_eventlog() elif key == "g": self.master.state.set_focus(0) signals.flowlist_change.send(self) elif key == "G": self.master.state.set_focus(self.master.state.flow_count()) signals.flowlist_change.send(self) elif key == "f": signals.status_prompt.send( prompt = "Filter View", text = self.master.state.filter_txt, callback = self.master.set_view_filter ) elif key == "L": signals.status_prompt_path.send( self, prompt = "Load flows", callback = self.master.load_flows_callback ) elif key == "n": signals.status_prompt_onekey.send( prompt = "Method", keys = common.METHOD_OPTIONS, callback = self.get_method ) elif key == "F": self.master.toggle_follow_flows() elif key == "W": if self.master.options.outfile: self.master.options.outfile = None else: signals.status_prompt_path.send( self, prompt="Stream flows to", callback= lambda path: self.master.options.update(outfile=(path, "ab")) ) else: return urwid.ListBox.keypress(self, size, key)
def keypress(self, size, key): key = common.shortcuts(key) if key == "A": for f in self.master.view: if f.intercepted: f.resume() self.master.view.update(f) elif key == "z": self.master.view.clear() elif key == "Z": self.master.view.clear_not_marked() elif key == "g": if len(self.master.view): self.master.view.focus.index = 0 elif key == "G": if len(self.master.view): self.master.view.focus.index = len(self.master.view) - 1 elif key == "L": signals.status_prompt_path.send( self, prompt = "Load flows", callback = self.master.load_flows_callback ) elif key == "M": self.master.view.toggle_marked() elif key == "n": signals.status_prompt_onekey.send( prompt = "Method", keys = common.METHOD_OPTIONS, callback = self.get_method ) elif key == "o": orders = [(i[1], i[0]) for i in view.orders] lookup = dict([(i[0], i[1]) for i in view.orders]) def change_order(k): self.master.options.console_order = lookup[k] signals.status_prompt_onekey.send( prompt = "Order", keys = orders, callback = change_order ) else: return urwid.ListBox.keypress(self, size, key)
def keypress(self, size, key): if self.walker.edit_row: if key in ["esc"]: self.walker.stop_edit() elif key == "tab": pf, pfc = self.walker.focus, self.walker.focus_col self.walker.tab_next() if self.walker.focus == pf and self.walker.focus_col != pfc: self.walker.start_edit() else: self._w.keypress(size, key) return None key = common.shortcuts(key) column = self.columns[self.walker.focus_col] if key in ["q", "esc"]: res = [] for i in self.walker.lst: if not i[1] and any([x for x in i[0]]): res.append(i[0]) self.callback(self.data_out(res), *self.cb_args, **self.cb_kwargs) signals.pop_view_state.send(self) elif key == "g": self.walker.set_focus(0) elif key == "G": self.walker.set_focus(len(self.walker.lst) - 1) elif key in ["h", "left"]: self.walker.left() elif key in ["l", "right"]: self.walker.right() elif key == "tab": self.walker.tab_next() elif key == "a": self.walker.add() elif key == "A": self.walker.insert() elif key == "d": self.walker.delete_focus() elif column.keypress(key, self) and not self.handle_key(key): return self._w.keypress(size, key)
def keypress(self, xxx_todo_changeme, key): (maxcol, ) = xxx_todo_changeme key = common.shortcuts(key) if key == "E": signals.status_prompt_onekey.send( self, prompt="Export to file", keys=[(e[0], e[1]) for e in export.EXPORTERS], callback=common.export_to_clip_or_file, args=(None, self.flow, common.ask_save_path)) # elif key == "C": # signals.status_prompt_onekey.send( # self, # prompt = "Export to clipboard", # keys = [(e[0], e[1]) for e in export.EXPORTERS], # callback = common.export_to_clip_or_file, # args = (None, self.flow, common.copy_to_clipboard_or_prompt) # ) elif key == "b": common.ask_save_body(None, self.flow) else: return key
def keypress(self, xxx_todo_changeme, key): (maxcol, ) = xxx_todo_changeme key = common.shortcuts(key) if key == "a": self.flow.resume(self.master) signals.flowlist_change.send(self) elif key == "d": if self.flow.killable: self.flow.kill(self.master) self.master.view.remove(self.master.view.focus.flow) elif key == "D": cp = self.flow.copy() self.master.view.add(cp) self.master.view.focus.flow = cp elif key == "m": self.flow.marked = not self.flow.marked signals.flowlist_change.send(self) elif key == "M": self.master.view.toggle_marked() elif key == "r": try: self.master.replay_request(self.flow) except exceptions.ReplayException as e: signals.add_log("Replay error: %s" % e, "warn") signals.flowlist_change.send(self) elif key == "S": def stop_server_playback(response): if response == "y": self.master.options.server_replay = [] a = self.master.addons.get("serverplayback") if a.count(): signals.status_prompt_onekey.send( prompt="Stop current server replay?", keys=( ("yes", "y"), ("no", "n"), ), callback=stop_server_playback, ) else: signals.status_prompt_onekey.send( prompt="Server Replay", keys=( ("all flows", "a"), ("this flow", "t"), ), callback=self.server_replay_prompt, ) elif key == "U": for f in self.master.view: f.marked = False signals.flowlist_change.send(self) elif key == "V": if not self.flow.modified(): signals.status_message.send(message="Flow not modified.") return self.flow.revert() signals.flowlist_change.send(self) signals.status_message.send(message="Reverted.") elif key == "w": signals.status_prompt_onekey.send( self, prompt="Save", keys=( ("listed flows", "l"), ("this flow", "t"), ), callback=self.save_flows_prompt, ) elif key == "X": if self.flow.killable: self.flow.kill(self.master) elif key == "enter": if self.flow.request: self.master.view_flow(self.flow) elif key == "|": signals.status_prompt_path.send( prompt="Send flow to script", callback=self.master.run_script_once, args=(self.flow, )) elif key == "E": signals.status_prompt_onekey.send( self, prompt="Export to file", keys=[(e[0], e[1]) for e in export.EXPORTERS], callback=common.export_to_clip_or_file, args=(None, self.flow, common.ask_save_path)) elif key == "C": signals.status_prompt_onekey.send( self, prompt="Export to clipboard", keys=[(e[0], e[1]) for e in export.EXPORTERS], callback=common.export_to_clip_or_file, args=(None, self.flow, common.copy_to_clipboard_or_prompt)) elif key == "b": common.ask_save_body(None, self.flow) else: return key
def keypress(self, size, key): key = common.shortcuts(key) if key == "enter": self.callback(self.choices[self.walker.index]) signals.pop_view_state.send(self) return super().keypress(size, key)
def keypress(self, size, key): conn = None # type: Optional[Union[http.HTTPRequest, http.HTTPResponse]] if self.tab_offset == TAB_REQ: conn = self.flow.request elif self.tab_offset == TAB_RESP: conn = self.flow.response key = super().keypress(size, key) # Special case: Space moves over to the next flow. # We need to catch that before applying common.shortcuts() if key == " ": self.view_next_flow(self.flow) return key = common.shortcuts(key) if key in ("up", "down", "page up", "page down"): # Pass scroll events to the wrapped widget self._w.keypress(size, key) elif key == "a": self.flow.resume(self.master) signals.flow_change.send(self, flow = self.flow) elif key == "A": self.master.accept_all() signals.flow_change.send(self, flow = self.flow) elif key == "d": if self.flow.killable: self.flow.kill(self.master) self.view.remove(self.flow) if not self.view.focus.flow: self.master.view_flowlist() else: self.view_flow(self.view.focus.flow) elif key == "D": cp = self.flow.copy() self.master.view.add(cp) self.master.view.focus.flow = cp self.view_flow(cp) signals.status_message.send(message="Duplicated.") elif key == "p": self.view_prev_flow(self.flow) elif key == "r": try: self.master.replay_request(self.flow) except exceptions.ReplayException as e: signals.add_log("Replay error: %s" % e, "warn") signals.flow_change.send(self, flow = self.flow) elif key == "V": if self.flow.modified(): self.flow.revert() signals.flow_change.send(self, flow = self.flow) signals.status_message.send(message="Reverted.") else: signals.status_message.send(message="Flow not modified.") elif key == "W": signals.status_prompt_path.send( prompt = "Save this flow", callback = self.master.save_one_flow, args = (self.flow,) ) elif key == "|": signals.status_prompt_path.send( prompt = "Send flow to script", callback = self.master.run_script_once, args = (self.flow,) ) elif key == "e": if self.tab_offset == TAB_REQ: signals.status_prompt_onekey.send( prompt="Edit request", keys=( ("cookies", "c"), ("query", "q"), ("path", "p"), ("url", "u"), ("header", "h"), ("form", "f"), ("raw body", "r"), ("method", "m"), ), callback=self.edit ) elif self.tab_offset == TAB_RESP: signals.status_prompt_onekey.send( prompt="Edit response", keys=( ("cookies", "c"), ("code", "o"), ("message", "m"), ("header", "h"), ("raw body", "r"), ), callback=self.edit ) else: signals.status_message.send( message="Tab to the request or response", expire=1 ) elif key in set("bfgmxvzEC") and not conn: signals.status_message.send( message = "Tab to the request or response", expire = 1 ) return elif key == "b": if self.tab_offset == TAB_REQ: common.ask_save_body("q", self.flow) else: common.ask_save_body("s", self.flow) elif key == "f": self.view.settings[self.flow][(self.tab_offset, "fullcontents")] = True signals.flow_change.send(self, flow = self.flow) signals.status_message.send(message="Loading all body data...") elif key == "m": p = list(contentviews.view_prompts) p.insert(0, ("Clear", "C")) signals.status_prompt_onekey.send( self, prompt = "Display mode", keys = p, callback = self.change_this_display_mode ) elif key == "E": if self.tab_offset == TAB_REQ: scope = "q" else: scope = "s" signals.status_prompt_onekey.send( self, prompt = "Export to file", keys = [(e[0], e[1]) for e in export.EXPORTERS], callback = common.export_to_clip_or_file, args = (scope, self.flow, common.ask_save_path) ) elif key == "C": if self.tab_offset == TAB_REQ: scope = "q" else: scope = "s" signals.status_prompt_onekey.send( self, prompt = "Export to clipboard", keys = [(e[0], e[1]) for e in export.EXPORTERS], callback = common.export_to_clip_or_file, args = (scope, self.flow, common.copy_to_clipboard_or_prompt) ) elif key == "x": conn.content = None signals.flow_change.send(self, flow=self.flow) elif key == "v": if conn.raw_content: t = conn.headers.get("content-type") if "EDITOR" in os.environ or "PAGER" in os.environ: self.master.spawn_external_viewer(conn.get_content(strict=False), t) else: signals.status_message.send( message = "Error! Set $EDITOR or $PAGER." ) elif key == "z": self.flow.backup() e = conn.headers.get("content-encoding", "identity") if e != "identity": try: conn.decode() except ValueError: signals.status_message.send( message = "Could not decode - invalid data?" ) else: signals.status_prompt_onekey.send( prompt = "Select encoding: ", keys = ( ("gzip", "z"), ("deflate", "d"), ("brotli", "b"), ), callback = self.encode_callback, args = (conn,) ) signals.flow_change.send(self, flow = self.flow) else: # Key is not handled here. return key
def keypress(self, xxx_todo_changeme, key): (maxcol,) = xxx_todo_changeme key = common.shortcuts(key) if key == "a": self.flow.resume(self.master) signals.flowlist_change.send(self) elif key == "d": if self.flow.killable: self.flow.kill(self.master) self.master.view.remove(self.master.view.focus.flow) elif key == "D": cp = self.flow.copy() self.master.view.add(cp) self.master.view.focus.flow = cp elif key == "m": self.flow.marked = not self.flow.marked signals.flowlist_change.send(self) elif key == "M": self.master.view.toggle_marked() elif key == "r": try: self.master.replay_request(self.flow) except exceptions.ReplayException as e: signals.add_log("Replay error: %s" % e, "warn") signals.flowlist_change.send(self) elif key == "S": def stop_server_playback(response): if response == "y": self.master.options.server_replay = [] a = self.master.addons.get("serverplayback") if a.count(): signals.status_prompt_onekey.send( prompt = "Stop current server replay?", keys = ( ("yes", "y"), ("no", "n"), ), callback = stop_server_playback, ) else: signals.status_prompt_onekey.send( prompt = "Server Replay", keys = ( ("all flows", "a"), ("this flow", "t"), ), callback = self.server_replay_prompt, ) elif key == "U": for f in self.master.view: f.marked = False signals.flowlist_change.send(self) elif key == "V": if not self.flow.modified(): signals.status_message.send(message="Flow not modified.") return self.flow.revert() signals.flowlist_change.send(self) signals.status_message.send(message="Reverted.") elif key == "w": signals.status_prompt_onekey.send( self, prompt = "Save", keys = ( ("listed flows", "l"), ("this flow", "t"), ), callback = self.save_flows_prompt, ) elif key == "X": if self.flow.killable: self.flow.kill(self.master) elif key == "enter": if self.flow.request: self.master.view_flow(self.flow) elif key == "|": signals.status_prompt_path.send( prompt = "Send flow to script", callback = self.master.run_script_once, args = (self.flow,) ) elif key == "E": signals.status_prompt_onekey.send( self, prompt = "Export to file", keys = [(e[0], e[1]) for e in export.EXPORTERS], callback = common.export_to_clip_or_file, args = (None, self.flow, common.ask_save_path) ) elif key == "C": signals.status_prompt_onekey.send( self, prompt = "Export to clipboard", keys = [(e[0], e[1]) for e in export.EXPORTERS], callback = common.export_to_clip_or_file, args = (None, self.flow, common.copy_to_clipboard_or_prompt) ) elif key == "b": common.ask_save_body(None, self.flow) else: return key
def keypress(self, size, key): conn = None # type: Optional[Union[http.HTTPRequest, http.HTTPResponse]] if self.tab_offset == TAB_REQ: conn = self.flow.request elif self.tab_offset == TAB_RESP: conn = self.flow.response key = super().keypress(size, key) # Special case: Space moves over to the next flow. # We need to catch that before applying common.shortcuts() if key == " ": self.view_next_flow(self.flow) return key = common.shortcuts(key) if key in ("up", "down", "page up", "page down"): # Pass scroll events to the wrapped widget self._w.keypress(size, key) elif key == "a": self.flow.resume(self.master) signals.flow_change.send(self, flow=self.flow) elif key == "A": self.master.accept_all() signals.flow_change.send(self, flow=self.flow) elif key == "d": if self.flow.killable: self.flow.kill(self.master) self.view.remove(self.flow) if not self.view.focus.flow: self.master.view_flowlist() else: self.view_flow(self.view.focus.flow) elif key == "D": cp = self.flow.copy() self.master.view.add(cp) self.master.view.focus.flow = cp self.view_flow(cp) signals.status_message.send(message="Duplicated.") elif key == "p": self.view_prev_flow(self.flow) elif key == "r": try: self.master.replay_request(self.flow) except exceptions.ReplayException as e: signals.add_log("Replay error: %s" % e, "warn") signals.flow_change.send(self, flow=self.flow) elif key == "V": if self.flow.modified(): self.flow.revert() signals.flow_change.send(self, flow=self.flow) signals.status_message.send(message="Reverted.") else: signals.status_message.send(message="Flow not modified.") elif key == "W": signals.status_prompt_path.send(prompt="Save this flow", callback=self.master.save_one_flow, args=(self.flow, )) elif key == "|": signals.status_prompt_path.send( prompt="Send flow to script", callback=self.master.run_script_once, args=(self.flow, )) elif key == "e": if self.tab_offset == TAB_REQ: signals.status_prompt_onekey.send(prompt="Edit request", keys=( ("cookies", "c"), ("query", "q"), ("path", "p"), ("url", "u"), ("header", "h"), ("form", "f"), ("raw body", "r"), ("method", "m"), ), callback=self.edit) elif self.tab_offset == TAB_RESP: signals.status_prompt_onekey.send(prompt="Edit response", keys=( ("cookies", "c"), ("code", "o"), ("message", "m"), ("header", "h"), ("raw body", "r"), ), callback=self.edit) else: signals.status_message.send( message="Tab to the request or response", expire=1) elif key in set("bfgmxvzEC") and not conn: signals.status_message.send( message="Tab to the request or response", expire=1) return elif key == "b": if self.tab_offset == TAB_REQ: common.ask_save_body("q", self.flow) else: common.ask_save_body("s", self.flow) elif key == "f": self.view.settings[self.flow][(self.tab_offset, "fullcontents")] = True signals.flow_change.send(self, flow=self.flow) signals.status_message.send(message="Loading all body data...") elif key == "m": p = list(contentviews.view_prompts) p.insert(0, ("Clear", "C")) signals.status_prompt_onekey.send( self, prompt="Display mode", keys=p, callback=self.change_this_display_mode) elif key == "E": if self.tab_offset == TAB_REQ: scope = "q" else: scope = "s" signals.status_prompt_onekey.send( self, prompt="Export to file", keys=[(e[0], e[1]) for e in export.EXPORTERS], callback=common.export_to_clip_or_file, args=(scope, self.flow, common.ask_save_path)) elif key == "C": if self.tab_offset == TAB_REQ: scope = "q" else: scope = "s" signals.status_prompt_onekey.send( self, prompt="Export to clipboard", keys=[(e[0], e[1]) for e in export.EXPORTERS], callback=common.export_to_clip_or_file, args=(scope, self.flow, common.copy_to_clipboard_or_prompt)) elif key == "x": conn.content = None signals.flow_change.send(self, flow=self.flow) elif key == "v": if conn.raw_content: t = conn.headers.get("content-type") if "EDITOR" in os.environ or "PAGER" in os.environ: self.master.spawn_external_viewer( conn.get_content(strict=False), t) else: signals.status_message.send( message="Error! Set $EDITOR or $PAGER.") elif key == "z": self.flow.backup() e = conn.headers.get("content-encoding", "identity") if e != "identity": try: conn.decode() except ValueError: signals.status_message.send( message="Could not decode - invalid data?") else: signals.status_prompt_onekey.send( prompt="Select encoding: ", keys=( ("gzip", "z"), ("deflate", "d"), ("brotli", "b"), ), callback=self.encode_callback, args=(conn, )) signals.flow_change.send(self, flow=self.flow) else: # Key is not handled here. return key