diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-01-19 10:41:49 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-01-19 10:41:49 (GMT) |
commit | d5d2cd149f78ba990526096e62df9f380dacfc12 (patch) | |
tree | 9be0cc8d70ab6acf0b21935b39ae5dda252f697b /Tools | |
parent | 0fdb90cafe596a03a5c3005a21e8fa2a230803e5 (diff) | |
download | cpython-d5d2cd149f78ba990526096e62df9f380dacfc12.zip cpython-d5d2cd149f78ba990526096e62df9f380dacfc12.tar.gz cpython-d5d2cd149f78ba990526096e62df9f380dacfc12.tar.bz2 |
Color all word instances of "as" after "import", & on the same line, as if
keywords. Cheap approximation to the truth.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/idle/ColorDelegator.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Tools/idle/ColorDelegator.py b/Tools/idle/ColorDelegator.py index 77edfe8..6722cfd 100644 --- a/Tools/idle/ColorDelegator.py +++ b/Tools/idle/ColorDelegator.py @@ -28,6 +28,7 @@ def make_pat(): prog = re.compile(make_pat(), re.S) idprog = re.compile(r"\s+(\w+)", re.S) +asprog = re.compile(r".*?\b(as)\b", re.S) class ColorDelegator(Delegator): @@ -35,6 +36,7 @@ class ColorDelegator(Delegator): Delegator.__init__(self) self.prog = prog self.idprog = idprog + self.asprog = asprog def setdelegate(self, delegate): if self.delegate is not None: @@ -198,6 +200,17 @@ class ColorDelegator(Delegator): self.tag_add("DEFINITION", head + "+%dc" % a, head + "+%dc" % b) + elif value == "import": + # color all the "as" words on same line; + # cheap approximation to the truth + while 1: + m1 = self.asprog.match(chars, b) + if not m1: + break + a, b = m1.span(1) + self.tag_add("KEYWORD", + head + "+%dc" % a, + head + "+%dc" % b) m = self.prog.search(chars, m.end()) if "SYNC" in self.tag_names(next + "-1c"): head = next |