1
import commander.commands as commands
5
from xml.sax import saxutils
8
__commander_module__ = True
9
__root__ = ['/', 'find_i', '//', 'r/', 'r//']
11
class TextFinder(finder.Finder):
12
def __init__(self, entry, flags):
13
finder.Finder.__init__(self, entry)
17
def do_find(self, bounds):
18
buf = self.view.get_buffer()
21
buf.set_search_text(self.findstr, self.flags)
23
ret = map(lambda x: x.copy(), bounds)
25
if buf.search_forward(bounds[0], bounds[1], ret[0], ret[1]):
30
def __default__(entry, argstr):
31
"""Find in document: find <text>
33
Quickly find phrases in the document"""
34
fd = TextFinder(entry, gedit.SEARCH_CASE_SENSITIVE)
37
def _find_insensitive(entry, argstr):
38
"""Find in document (case insensitive): find-i <text>
40
Quickly find phrases in the document (case insensitive)"""
41
fd = TextFinder(entry, 0)
44
def replace(entry, findstr, replstr=None):
45
"""Find/replace in document: find.replace <find> [<replace>]
47
Quickly find and replace phrases in the document"""
48
fd = TextFinder(entry, gedit.SEARCH_CASE_SENSITIVE)
49
yield fd.replace(findstr, False, replstr)
51
def replace_i(entry, findstr, replstr=None):
52
"""Find/replace all in document (case insensitive): find.replace-i <find> [<replace>]
54
Quickly find and replace phrases in the document (case insensitive)"""
55
fd = TextFinder(entry, 0)
56
yield fd.replace(findstr, True, replstr)
58
def replace_all(entry, findstr, replstr=None):
59
"""Find/replace all in document: find.replace-all <find> [<replace>]
61
Quickly find and replace all phrases in the document"""
62
fd = TextFinder(entry, gedit.SEARCH_CASE_SENSITIVE)
63
yield fd.replace(findstr, True, replstr)
65
def replace_all_i(entry, findstr, replstr=None):
66
"""Find/replace all in document (case insensitive): find.replace-all-i <find> [<replace>]
68
Quickly find and replace all phrases in the document (case insensitive)"""
69
fd = TextFinder(entry,0)
70
yield fd.replace(findstr, True, replstr)
72
locals()['/'] = __default__
73
locals()['find_i'] = _find_insensitive
74
locals()['//'] = replace
75
locals()['r/'] = regex.__default__
76
locals()['r//'] = regex.replace