Kaydet (Commit) 0bc3d985 authored tarafından Kurt B. Kaiser's avatar Kurt B. Kaiser

1. Bug in Patch 805830 fixed by Nigel Rowe

2. Convert 1/0 to True/False
3. Fix a couple of long lines

M ColorDelegator.py
M NEWS.txt
üst 325d169a
...@@ -6,12 +6,7 @@ from Tkinter import * ...@@ -6,12 +6,7 @@ from Tkinter import *
from Delegator import Delegator from Delegator import Delegator
from configHandler import idleConf from configHandler import idleConf
#$ event <<toggle-auto-coloring>> DEBUG = False
#$ win <Control-slash>
#$ unix <Control-slash>
DEBUG = 0
def any(name, list): def any(name, list):
return "(?P<%s>" % name + "|".join(list) + ")" return "(?P<%s>" % name + "|".join(list) + ")"
...@@ -20,14 +15,17 @@ def make_pat(): ...@@ -20,14 +15,17 @@ def make_pat():
kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b"
builtinlist = [str(name) for name in dir(__builtin__) builtinlist = [str(name) for name in dir(__builtin__)
if not name.startswith('_')] if not name.startswith('_')]
builtin = r"([^\\.]\b|^)" + any("BUILTIN", builtinlist) + r"\b" # self.file = file("file") :
# 1st 'file' colorized normal, 2nd as builtin, 3rd as comment
builtin = r"([^.'\"\\]\b|^)" + any("BUILTIN", builtinlist) + r"\b"
comment = any("COMMENT", [r"#[^\n]*"]) comment = any("COMMENT", [r"#[^\n]*"])
sqstring = r"(\b[rR])?'[^'\\\n]*(\\.[^'\\\n]*)*'?" sqstring = r"(\b[rR])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
dqstring = r'(\b[rR])?"[^"\\\n]*(\\.[^"\\\n]*)*"?' dqstring = r'(\b[rR])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
sq3string = r"(\b[rR])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" sq3string = r"(\b[rR])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
dq3string = r'(\b[rR])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' dq3string = r'(\b[rR])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
string = any("STRING", [sq3string, dq3string, sqstring, dqstring]) string = any("STRING", [sq3string, dq3string, sqstring, dqstring])
return kw + "|" + builtin + "|" + comment + "|" + string + "|" + any("SYNC", [r"\n"]) return kw + "|" + builtin + "|" + comment + "|" + string +\
"|" + any("SYNC", [r"\n"])
prog = re.compile(make_pat(), re.S) prog = re.compile(make_pat(), re.S)
idprog = re.compile(r"\s+(\w+)", re.S) idprog = re.compile(r"\s+(\w+)", re.S)
...@@ -86,8 +84,8 @@ class ColorDelegator(Delegator): ...@@ -86,8 +84,8 @@ class ColorDelegator(Delegator):
self.notify_range(index1) self.notify_range(index1)
after_id = None after_id = None
allow_colorizing = 1 allow_colorizing = True
colorizing = 0 colorizing = False
def notify_range(self, index1, index2=None): def notify_range(self, index1, index2=None):
self.tag_add("TODO", index1, index2) self.tag_add("TODO", index1, index2)
...@@ -95,7 +93,7 @@ class ColorDelegator(Delegator): ...@@ -95,7 +93,7 @@ class ColorDelegator(Delegator):
if DEBUG: print "colorizing already scheduled" if DEBUG: print "colorizing already scheduled"
return return
if self.colorizing: if self.colorizing:
self.stop_colorizing = 1 self.stop_colorizing = True
if DEBUG: print "stop colorizing" if DEBUG: print "stop colorizing"
if self.allow_colorizing: if self.allow_colorizing:
if DEBUG: print "schedule colorizing" if DEBUG: print "schedule colorizing"
...@@ -109,8 +107,8 @@ class ColorDelegator(Delegator): ...@@ -109,8 +107,8 @@ class ColorDelegator(Delegator):
self.after_id = None self.after_id = None
if DEBUG: print "cancel scheduled recolorizer" if DEBUG: print "cancel scheduled recolorizer"
self.after_cancel(after_id) self.after_cancel(after_id)
self.allow_colorizing = 0 self.allow_colorizing = False
self.stop_colorizing = 1 self.stop_colorizing = True
if close_when_done: if close_when_done:
if not self.colorizing: if not self.colorizing:
close_when_done.destroy() close_when_done.destroy()
...@@ -125,12 +123,13 @@ class ColorDelegator(Delegator): ...@@ -125,12 +123,13 @@ class ColorDelegator(Delegator):
self.after_cancel(after_id) self.after_cancel(after_id)
if self.allow_colorizing and self.colorizing: if self.allow_colorizing and self.colorizing:
if DEBUG: print "stop colorizing" if DEBUG: print "stop colorizing"
self.stop_colorizing = 1 self.stop_colorizing = True
self.allow_colorizing = not self.allow_colorizing self.allow_colorizing = not self.allow_colorizing
if self.allow_colorizing and not self.colorizing: if self.allow_colorizing and not self.colorizing:
self.after_id = self.after(1, self.recolorize) self.after_id = self.after(1, self.recolorize)
if DEBUG: if DEBUG:
print "auto colorizing turned", self.allow_colorizing and "on" or "off" print "auto colorizing turned",\
self.allow_colorizing and "on" or "off"
return "break" return "break"
def recolorize(self): def recolorize(self):
...@@ -145,15 +144,15 @@ class ColorDelegator(Delegator): ...@@ -145,15 +144,15 @@ class ColorDelegator(Delegator):
if DEBUG: print "already colorizing" if DEBUG: print "already colorizing"
return return
try: try:
self.stop_colorizing = 0 self.stop_colorizing = False
self.colorizing = 1 self.colorizing = True
if DEBUG: print "colorizing..." if DEBUG: print "colorizing..."
t0 = time.clock() t0 = time.clock()
self.recolorize_main() self.recolorize_main()
t1 = time.clock() t1 = time.clock()
if DEBUG: print "%.3f seconds" % (t1-t0) if DEBUG: print "%.3f seconds" % (t1-t0)
finally: finally:
self.colorizing = 0 self.colorizing = False
if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"):
if DEBUG: print "reschedule colorizing" if DEBUG: print "reschedule colorizing"
self.after_id = self.after(1, self.recolorize) self.after_id = self.after(1, self.recolorize)
...@@ -164,7 +163,7 @@ class ColorDelegator(Delegator): ...@@ -164,7 +163,7 @@ class ColorDelegator(Delegator):
def recolorize_main(self): def recolorize_main(self):
next = "1.0" next = "1.0"
while 1: while True:
item = self.tag_nextrange("TODO", next) item = self.tag_nextrange("TODO", next)
if not item: if not item:
break break
...@@ -179,7 +178,7 @@ class ColorDelegator(Delegator): ...@@ -179,7 +178,7 @@ class ColorDelegator(Delegator):
chars = "" chars = ""
next = head next = head
lines_to_get = 1 lines_to_get = 1
ok = 0 ok = False
while not ok: while not ok:
mark = next mark = next
next = self.index(mark + "+%d lines linestart" % next = self.index(mark + "+%d lines linestart" %
...@@ -211,7 +210,7 @@ class ColorDelegator(Delegator): ...@@ -211,7 +210,7 @@ class ColorDelegator(Delegator):
elif value == "import": elif value == "import":
# color all the "as" words on same line; # color all the "as" words on same line;
# cheap approximation to the truth # cheap approximation to the truth
while 1: while True:
m1 = self.asprog.match(chars, b) m1 = self.asprog.match(chars, b)
if not m1: if not m1:
break break
...@@ -224,7 +223,7 @@ class ColorDelegator(Delegator): ...@@ -224,7 +223,7 @@ class ColorDelegator(Delegator):
head = next head = next
chars = "" chars = ""
else: else:
ok = 0 ok = False
if not ok: if not ok:
# We're in an inconsistent state, and the call to # We're in an inconsistent state, and the call to
# update may tell us to stop. It may also change # update may tell us to stop. It may also change
......
...@@ -3,7 +3,12 @@ What's New in IDLE 1.1a0? ...@@ -3,7 +3,12 @@ What's New in IDLE 1.1a0?
*Release date: XX-XXX-2004* *Release date: XX-XXX-2004*
- If the normal background is changed via Configure/Highlighting, it will update
immediately, thanks to the previously mentioned patch.
- Add a highlight theme for builtin keywords. Python Patch 805830 Nigel Rowe - Add a highlight theme for builtin keywords. Python Patch 805830 Nigel Rowe
This also fixed IDLEfork bug [ 693418 ] Normal text background color not refreshed
and Python bug [897872 ] Unknown color name on HP-UX
- rpc.py:SocketIO - Large modules were generating large pickles when downloaded - rpc.py:SocketIO - Large modules were generating large pickles when downloaded
to the execution server. The return of the OK response from the subprocess to the execution server. The return of the OK response from the subprocess
......
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