Kaydet (Commit) 26c2cb4b authored tarafından Guido van Rossum's avatar Guido van Rossum

Tim Peters strikes again:

Ho ho ho -- that's trickier than it sounded!  The colorizer is working with
"line.col" strings instead of Text marks, and the absolute coordinates of
the point of interest can change across the self.update call (voice of
baffled experience, when two quick backspaces no longer fooled it, but a
backspace followed by a quick ENTER did <wink>).

Anyway, the attached appears to do the trick.  CPU usage goes way up when
typing quickly into a long triple-quoted string, but the latency is fine for
me (a relatively fast typist on a relatively slow machine).  Most of the
changes here are left over from reducing the # of vrbl names to help me
reason about the logic better; I hope the code is a *little* easier to
üst c020e2d3
This diff is collapsed.
......@@ -165,7 +165,6 @@ class ColorDelegator(Delegator):
def recolorize_main(self):
next = "1.0"
was_ok = is_ok = 0
while 1:
item = self.tag_nextrange("TODO", next)
if not item:
......@@ -179,14 +178,15 @@ class ColorDelegator(Delegator):
head = "1.0"
chars = ""
mark = head
next = head
lines_to_get = 1
is_ok = was_ok = 0
while not (was_ok and is_ok):
ok = 0
while not ok:
mark = next
next = self.index(mark + "+%d lines linestart" %
lines_to_get)
lines_to_get = min(lines_to_get * 2, 100)
was_ok = "SYNC" in self.tag_names(next + "-1c")
ok = "SYNC" in self.tag_names(next + "-1c")
line = self.get(mark, next)
##print head, "get", mark, next, "->", `line`
if not line:
......@@ -196,7 +196,6 @@ class ColorDelegator(Delegator):
chars = chars + line
m = self.prog.search(chars)
while m:
i, j = m.span()
for key, value in m.groupdict().items():
if value:
a, b = m.span(key)
......@@ -210,12 +209,20 @@ class ColorDelegator(Delegator):
self.tag_add("DEFINITION",
head + "+%dc" % a,
head + "+%dc" % b)
m = self.prog.search(chars, j)
is_ok = "SYNC" in self.tag_names(next + "-1c")
mark = next
if is_ok:
head = mark
m = self.prog.search(chars, m.end())
if "SYNC" in self.tag_names(next + "-1c"):
head = next
chars = ""
else:
ok = 0
if not ok:
# We're in an inconsistent state, and the call to
# update may tell us to stop. It may also change
# the correct value for "next" (since this is a
# line.col string, not a true mark). So leave a
# crumb telling the next invocation to resume here
# in case update tells us to leave.
self.tag_add("TODO", next)
self.update()
if self.stop_colorizing:
if __debug__: print "colorizing stopped"
......
......@@ -407,7 +407,7 @@ class PyShell(OutputWindow):
def begin(self):
self.resetoutput()
self.write("Python %s on %s\n%s\nIDLE %s\n" %
self.write("Python %s on %s\n%s\nIDLE %s -- press F1 for help\n" %
(sys.version, sys.platform, sys.copyright,
idlever.IDLE_VERSION))
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment