File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,13 +28,15 @@ def make_pat():
2828
2929prog = re .compile (make_pat (), re .S )
3030idprog = re .compile (r"\s+(\w+)" , re .S )
31+ asprog = re .compile (r".*?\b(as)\b" , re .S )
3132
3233class ColorDelegator (Delegator ):
3334
3435 def __init__ (self ):
3536 Delegator .__init__ (self )
3637 self .prog = prog
3738 self .idprog = idprog
39+ self .asprog = asprog
3840
3941 def setdelegate (self , delegate ):
4042 if self .delegate is not None :
@@ -198,6 +200,17 @@ def recolorize_main(self):
198200 self .tag_add ("DEFINITION" ,
199201 head + "+%dc" % a ,
200202 head + "+%dc" % b )
203+ elif value == "import" :
204+ # color all the "as" words on same line;
205+ # cheap approximation to the truth
206+ while 1 :
207+ m1 = self .asprog .match (chars , b )
208+ if not m1 :
209+ break
210+ a , b = m1 .span (1 )
211+ self .tag_add ("KEYWORD" ,
212+ head + "+%dc" % a ,
213+ head + "+%dc" % b )
201214 m = self .prog .search (chars , m .end ())
202215 if "SYNC" in self .tag_names (next + "-1c" ):
203216 head = next
You can’t perform that action at this time.
0 commit comments