From 54a7ee5f6f36a129fff343911e4002f7992f30eb Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Sat, 26 Dec 2015 20:57:11 -0800 Subject: [PATCH] Saved search now highlighted when switching segments, and cursor moved to end after a repeat --- omnivore/framework/minibuffer.py | 17 +++++++++++++++++ omnivore/framework/task.py | 1 + 2 files changed, 18 insertions(+) diff --git a/omnivore/framework/minibuffer.py b/omnivore/framework/minibuffer.py index d773b7c2..e1afcead 100644 --- a/omnivore/framework/minibuffer.py +++ b/omnivore/framework/minibuffer.py @@ -138,6 +138,10 @@ def get_result(self, show_error=True): text = None return text, error + def clear_selection(self): + p = self.text.GetInsertionPoint() + self.text.SetSelection(p, p) + def perform(self): """Execute the command associatied with this minibuffer""" value, error = self.get_result() @@ -166,6 +170,16 @@ def __init__(self, editor, command_cls, next_cls, prev_cls, next_match=False, pr self.prev_match = prev_match self.segment = editor.segment + def create_control(self, parent, **kwargs): + TextMinibuffer.create_control(self, parent, **kwargs) + + if self.initial: + self.perform() + # If using a previous search, select all text in case user wants to + # start over again + self.text.SetInsertionPointEnd() + self.text.SetSelection(0, self.text.GetLastPosition()) + def change_editor(self, editor): self.segment.clear_style_bits(match=True) self.editor = editor @@ -190,11 +204,13 @@ def next(self): if self.search_command is not None: cmd = self.next_cls(self.search_command) self.editor.process_command(cmd) + self.clear_selection() def prev(self): if self.search_command is not None: cmd = self.prev_cls(self.search_command) self.editor.process_command(cmd) + self.clear_selection() def perform(self): """Execute the command associatied with this minibuffer""" @@ -206,6 +222,7 @@ def perform(self): self.search_command = cmd self.editor.last_search_settings["find"] = value print self.editor.last_search_settings + self.clear_selection() def repeat(self, minibuffer=None): if minibuffer is not None: diff --git a/omnivore/framework/task.py b/omnivore/framework/task.py index 9a5c7c0b..f4f238f8 100644 --- a/omnivore/framework/task.py +++ b/omnivore/framework/task.py @@ -567,6 +567,7 @@ def show_minibuffer(self, minibuffer, **kwargs): repeat = False if info.minibuffer is not None: if info.minibuffer.is_repeat(minibuffer): + log.debug("Reusing old minibuffer control: %s" % info.minibuffer.control) repeat = True else: log.debug("Removing old minibuffer control: %s" % info.minibuffer.control)