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):
Delegator.__init__(self)
self.prog = prog
self.idprog = idprog
+ self.asprog = asprog
def setdelegate(self, delegate):
if self.delegate is not None:
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