[Python-checkins] CVS: python/dist/src/Tools/idle ColorDelegator.py,1.10,1.11

Tim Peters tim_one@users.sourceforge.net
Fri, 19 Jan 2001 02:41:52 -0800


Update of /cvsroot/python/python/dist/src/Tools/idle
In directory usw-pr-cvs1:/tmp/cvs-serv7925/python/dist/src/tools/idle

Modified Files:
	ColorDelegator.py 
Log Message:
Color all word instances of "as" after "import", & on the same line, as if
keywords.  Cheap approximation to the truth.


Index: ColorDelegator.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/idle/ColorDelegator.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** ColorDelegator.py	2000/03/07 17:55:32	1.10
--- ColorDelegator.py	2001/01/19 10:41:49	1.11
***************
*** 29,32 ****
--- 29,33 ----
  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):
***************
*** 36,39 ****
--- 37,41 ----
          self.prog = prog
          self.idprog = idprog
+         self.asprog = asprog
  
      def setdelegate(self, delegate):
***************
*** 197,200 ****
--- 199,213 ----
                                      a, b = m1.span(1)
                                      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)