Skip to content

Commit

Permalink
Saved search now highlighted when switching segments, and cursor move…
Browse files Browse the repository at this point in the history
…d to end after a repeat
  • Loading branch information
robmcmullen committed Dec 27, 2015
1 parent d9d86bf commit 54a7ee5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions omnivore/framework/minibuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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"""
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions omnivore/framework/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 54a7ee5

Please sign in to comment.