diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-03-29 15:14:56 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-03-29 15:14:56 +1300 |
commit | 80c4de5ca462a211fca33d45fe52441b246d4d03 (patch) | |
tree | 58b0720313ed83b906ce72960dc9f3984df976d4 /libmproxy/console/searchable.py | |
parent | bf012e0a891da1628c187c8b36aa63d03a1f09a5 (diff) | |
download | mitmproxy-80c4de5ca462a211fca33d45fe52441b246d4d03.tar.gz mitmproxy-80c4de5ca462a211fca33d45fe52441b246d4d03.tar.bz2 mitmproxy-80c4de5ca462a211fca33d45fe52441b246d4d03.zip |
Keep record of last search term
Diffstat (limited to 'libmproxy/console/searchable.py')
-rw-r--r-- | libmproxy/console/searchable.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libmproxy/console/searchable.py b/libmproxy/console/searchable.py index 5539ecb2..bd1288d5 100644 --- a/libmproxy/console/searchable.py +++ b/libmproxy/console/searchable.py @@ -14,11 +14,12 @@ class Highlight(urwid.AttrMap): class Searchable(urwid.ListBox): - def __init__(self, contents): + def __init__(self, state, contents): urwid.ListBox.__init__( self, urwid.SimpleFocusListWalker(contents) ) + self.state = state self.search_offset = 0 self.current_highlight = None self.search_term = None @@ -38,6 +39,7 @@ class Searchable(urwid.ListBox): return super(self.__class__, self).keypress(size, key) def set_search(self, text): + self.state.last_search = text self.search_term = text or None self.find_next(False) @@ -61,8 +63,11 @@ class Searchable(urwid.ListBox): def find_next(self, backwards): if not self.search_term: - self.set_highlight(None) - return + if self.state.last_search: + self.search_term = self.state.last_search + else: + self.set_highlight(None) + return # Start search at focus + 1 if backwards: rng = xrange(len(self.body)-1, -1, -1) |