d7124d67ff2a2fab60f63b1a1fe266cd0c2f1dd1
from SearchDialogBase
import SearchDialogBase
engine
= SearchEngine
.get(root
)
if not hasattr(engine
, "_searchdialog"):
engine
._searchdialog
= SearchDialog(root
, engine
)
return engine
._searchdialog
pat
= text
.get("sel.first", "sel.last")
return _setup(text
).open(text
,pat
)
return _setup(text
).find_again(text
)
def find_selection(text
):
return _setup(text
).find_selection(text
)
class SearchDialog(SearchDialogBase
):
def create_widgets(self
):
f
= SearchDialogBase
.create_widgets(self
)
self
.make_button("Find", self
.default_command
, 1)
def default_command(self
, event
=None):
if not self
.engine
.getprog():
if self
.find_again(self
.text
):
def find_again(self
, text
):
if not self
.engine
.getpat():
if not self
.engine
.getprog():
res
= self
.engine
.search_text(text
)
first
= "%d.%d" % (line
, i
)
last
= "%d.%d" % (line
, j
)
selfirst
= text
.index("sel.first")
sellast
= text
.index("sel.last")
if selfirst
== first
and sellast
== last
:
text
.tag_remove("sel", "1.0", "end")
text
.tag_add("sel", first
, last
)
text
.mark_set("insert", self
.engine
.isback() and first
or last
)
def find_selection(self
, text
):
pat
= text
.get("sel.first", "sel.last")
self
.engine
.setcookedpat(pat
)
return self
.find_again(text
)