From d41095c35ee49bf85a31a1830638fcc30afbe28e Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 8 Feb 2012 17:52:43 +1300 Subject: [PATCH] "i" shortcut to insert for KVEditor. --- libmproxy/console/__init__.py | 2 +- libmproxy/console/kveditor.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 30625ec3a..1b0ab35fb 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -486,7 +486,7 @@ class ConsoleMaster(flow.FlowMaster): ('offset', 'dark cyan', 'default'), # KV Editor - ('focusfield', 'white', 'dark blue'), + ('focusfield', 'black', 'light gray'), ('editfield', 'black', 'light cyan'), ] diff --git a/libmproxy/console/kveditor.py b/libmproxy/console/kveditor.py index 9b725590d..95b703bed 100644 --- a/libmproxy/console/kveditor.py +++ b/libmproxy/console/kveditor.py @@ -82,12 +82,18 @@ class KVWalker(urwid.ListWalker): self.focus = min(len(self.lst)-1, self.focus) self._modified() - def add(self): - self.focus = min(self.focus +1, len(self.lst)) + def _insert(self, pos): + self.focus = pos self.lst.insert(self.focus, ("", "")) self.focus_col = 0 self.start_edit() + def insert(self): + return self._insert(self.focus) + + def add(self): + return self._insert(min(self.focus + 1, len(self.lst))) + def start_edit(self): self.editing = KVItem(self.focus_col, True, self.maxk, *self.lst[self.focus]) self._modified() @@ -179,6 +185,8 @@ class KVEditor(common.WWrap): self.walker.tab_next() elif key == "a": self.walker.add() + elif key == "i": + self.walker.insert() elif key == "d": self.walker.delete_focus() elif key in ["enter", "e"]: