fix searching and make it use regexps. Roberto Aguilar

This commit is contained in:
Chris Jones 2011-08-20 13:19:18 +01:00
commit 00a887dd91
2 changed files with 13 additions and 7 deletions

View File

@ -1,6 +1,8 @@
terminator 0.96:
* Unity support for opening new windows (Lucian Adrian Grijincu)
* Fix searching with infinite scrollback (Julien Thewys #755077)
* Fix searching on Ubuntu 10.10 and 11.04, and implement searching
by regular expression (Roberto Aguilar #709018)
terminator 0.95:
* Add a configuration option to enable a DBus server

View File

@ -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)
@ -132,11 +135,11 @@ 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)
if index != -1:
matches = self.searchre.search(buffer)
if matches:
self.search_hit(self.searchrow)
self.searchrow += 1
return
@ -153,11 +156,11 @@ 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)
if index != -1:
matches = self.searchre.search(buffer)
if matches:
self.search_hit(self.searchrow)
self.searchrow -= 1
return
@ -187,6 +190,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')