From 189cce4507ffbec0b3e58cdd4683ac94cbf74aac Mon Sep 17 00:00:00 2001 From: Roberto Aguilar Date: Mon, 21 Mar 2011 22:57:18 -0700 Subject: [PATCH 1/2] Updated call to get_text_range() for search to work. Instead of using -1 to indicate the last character of a line, search the current row up to the next row. This appears to fix the search box for ubuntu 10.10. --- terminatorlib/searchbar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/terminatorlib/searchbar.py b/terminatorlib/searchbar.py index 46b65900..a238d694 100755 --- a/terminatorlib/searchbar.py +++ b/terminatorlib/searchbar.py @@ -131,8 +131,8 @@ class Searchbar(gtk.HBox): self.searchrow = startrow self.reslabel.set_text(_('No more results')) return - buffer = self.vte.get_text_range(self.searchrow, 0, - self.searchrow, -1, + buffer = self.vte.get_text_range(self.searchrow, 0, + self.searchrow+1, 0, self.search_character) index = buffer.find(self.searchstring) @@ -153,7 +153,7 @@ class Searchbar(gtk.HBox): self.reslabel.set_text(_('No more results')) return buffer = self.vte.get_text_range(self.searchrow, 0, - self.searchrow, -1, + self.searchrow+1, 0, self.search_character) index = buffer.find(self.searchstring) From 32de71d0180a71a20efe05d6ef21ba795c72d82a Mon Sep 17 00:00:00 2001 From: Roberto Aguilar Date: Tue, 22 Mar 2011 00:05:38 -0700 Subject: [PATCH 2/2] Updated code so search can be done with regex. --- terminatorlib/searchbar.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/terminatorlib/searchbar.py b/terminatorlib/searchbar.py index a238d694..9e334038 100755 --- a/terminatorlib/searchbar.py +++ b/terminatorlib/searchbar.py @@ -5,6 +5,7 @@ import gtk import gobject +import re from translation import _ from config import Config @@ -26,6 +27,7 @@ class Searchbar(gtk.HBox): config = None searchstring = None + searchre = None searchrow = None searchits = None @@ -117,6 +119,7 @@ class Searchbar(gtk.HBox): if searchtext != self.searchstring: self.searchrow = self.get_vte_buffer_range()[0] self.searchstring = searchtext + self.searchre = re.compile(searchtext) self.reslabel.set_text(_("Searching scrollback")) self.next.set_sensitive(True) @@ -135,8 +138,8 @@ class Searchbar(gtk.HBox): self.searchrow+1, 0, self.search_character) - index = buffer.find(self.searchstring) - if index != -1: + matches = self.searchre.search(buffer) + if matches: self.search_hit(self.searchrow) self.searchrow += 1 return @@ -156,8 +159,8 @@ class Searchbar(gtk.HBox): self.searchrow+1, 0, self.search_character) - index = buffer.find(self.searchstring) - if index != -1: + matches = self.searchre.search(buffer) + if matches: self.search_hit(self.searchrow) self.searchrow -= 1 return @@ -184,6 +187,7 @@ class Searchbar(gtk.HBox): """Trap and re-emit the end-search signal""" self.searchrow = 0 self.searchstring = None + self.searchre = None self.reslabel.set_text('') self.emit('end-search')