Updated code so search can be done with regex.
This commit is contained in:
parent
189cce4507
commit
32de71d018
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
|
import re
|
||||||
|
|
||||||
from translation import _
|
from translation import _
|
||||||
from config import Config
|
from config import Config
|
||||||
|
@ -26,6 +27,7 @@ class Searchbar(gtk.HBox):
|
||||||
config = None
|
config = None
|
||||||
|
|
||||||
searchstring = None
|
searchstring = None
|
||||||
|
searchre = None
|
||||||
searchrow = None
|
searchrow = None
|
||||||
|
|
||||||
searchits = None
|
searchits = None
|
||||||
|
@ -117,6 +119,7 @@ class Searchbar(gtk.HBox):
|
||||||
if searchtext != self.searchstring:
|
if searchtext != self.searchstring:
|
||||||
self.searchrow = self.get_vte_buffer_range()[0]
|
self.searchrow = self.get_vte_buffer_range()[0]
|
||||||
self.searchstring = searchtext
|
self.searchstring = searchtext
|
||||||
|
self.searchre = re.compile(searchtext)
|
||||||
|
|
||||||
self.reslabel.set_text(_("Searching scrollback"))
|
self.reslabel.set_text(_("Searching scrollback"))
|
||||||
self.next.set_sensitive(True)
|
self.next.set_sensitive(True)
|
||||||
|
@ -135,8 +138,8 @@ class Searchbar(gtk.HBox):
|
||||||
self.searchrow+1, 0,
|
self.searchrow+1, 0,
|
||||||
self.search_character)
|
self.search_character)
|
||||||
|
|
||||||
index = buffer.find(self.searchstring)
|
matches = self.searchre.search(buffer)
|
||||||
if index != -1:
|
if matches:
|
||||||
self.search_hit(self.searchrow)
|
self.search_hit(self.searchrow)
|
||||||
self.searchrow += 1
|
self.searchrow += 1
|
||||||
return
|
return
|
||||||
|
@ -156,8 +159,8 @@ class Searchbar(gtk.HBox):
|
||||||
self.searchrow+1, 0,
|
self.searchrow+1, 0,
|
||||||
self.search_character)
|
self.search_character)
|
||||||
|
|
||||||
index = buffer.find(self.searchstring)
|
matches = self.searchre.search(buffer)
|
||||||
if index != -1:
|
if matches:
|
||||||
self.search_hit(self.searchrow)
|
self.search_hit(self.searchrow)
|
||||||
self.searchrow -= 1
|
self.searchrow -= 1
|
||||||
return
|
return
|
||||||
|
@ -184,6 +187,7 @@ class Searchbar(gtk.HBox):
|
||||||
"""Trap and re-emit the end-search signal"""
|
"""Trap and re-emit the end-search signal"""
|
||||||
self.searchrow = 0
|
self.searchrow = 0
|
||||||
self.searchstring = None
|
self.searchstring = None
|
||||||
|
self.searchre = None
|
||||||
self.reslabel.set_text('')
|
self.reslabel.set_text('')
|
||||||
self.emit('end-search')
|
self.emit('end-search')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue