mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Speed up the search a bit -- don't drag a mark around...
This commit is contained in:
parent
cc0ade8cd5
commit
7b9bb05df9
1 changed files with 17 additions and 13 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import string
|
||||||
import re
|
import re
|
||||||
import tkSimpleDialog
|
import tkSimpleDialog
|
||||||
import tkMessageBox
|
import tkMessageBox
|
||||||
|
@ -52,24 +53,27 @@ class SearchBinding:
|
||||||
self.text.bell()
|
self.text.bell()
|
||||||
##print "No program"
|
##print "No program"
|
||||||
return "break"
|
return "break"
|
||||||
self.text.mark_set("find", "insert")
|
line, col = map(int,
|
||||||
while 1:
|
string.split(self.text.index("insert"), "."))
|
||||||
chars = self.text.get("find", "find lineend +1c")
|
chars = self.text.get("%d.0" % line, "%d.0" % (line+1))
|
||||||
##print "Searching", `chars`
|
while chars:
|
||||||
if not chars:
|
m = self.prog.search(chars, col)
|
||||||
self.text.bell()
|
|
||||||
##print "end of buffer"
|
|
||||||
break
|
|
||||||
m = self.prog.search(chars)
|
|
||||||
if m:
|
if m:
|
||||||
i, j = m.span()
|
i, j = m.span()
|
||||||
self.text.mark_set("insert", "find +%dc" % j)
|
self.text.mark_set("insert",
|
||||||
self.text.mark_set("find", "find +%dc" % i)
|
"%d.%d" % (line, j))
|
||||||
self.text.tag_remove("sel", "1.0", "end")
|
self.text.tag_remove("sel", "1.0", "end")
|
||||||
self.text.tag_add("sel", "find", "insert")
|
self.text.tag_add("sel",
|
||||||
|
"%d.%d" % (line, i),
|
||||||
|
"%d.%d" % (line, j))
|
||||||
self.text.see("insert")
|
self.text.see("insert")
|
||||||
break
|
break
|
||||||
self.text.mark_set("find", "find lineend +1c")
|
line = line + 1
|
||||||
|
col = 0
|
||||||
|
chars = self.text.get("%d.0" % line, "%d.0" % (line+1))
|
||||||
|
else:
|
||||||
|
# Not found
|
||||||
|
self.text.bell()
|
||||||
return "break"
|
return "break"
|
||||||
|
|
||||||
def goto_line_event(self, event):
|
def goto_line_event(self, event):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue