]> granicus.if.org Git - python/commitdiff
Add a highlight theme for builtin keywords. Python Patch 805830 Nigel Rowe
authorKurt B. Kaiser <kbk@shore.net>
Mon, 8 Mar 2004 18:15:31 +0000 (18:15 +0000)
committerKurt B. Kaiser <kbk@shore.net>
Mon, 8 Mar 2004 18:15:31 +0000 (18:15 +0000)
M ClassBrowser.py
M ColorDelegator.py
M EditorWindow.py
M NEWS.txt
M PyShell.py
M TreeWidget.py
M config-highlight.def
M configDialog.py
M configHandler.py

Lib/idlelib/ClassBrowser.py
Lib/idlelib/ColorDelegator.py
Lib/idlelib/EditorWindow.py
Lib/idlelib/NEWS.txt
Lib/idlelib/PyShell.py
Lib/idlelib/TreeWidget.py
Lib/idlelib/config-highlight.def
Lib/idlelib/configDialog.py
Lib/idlelib/configHandler.py

index 82f51915d20eef6bcfadd9878f4b3e0268bc93b3..e5a60a51341f2cb8135949a5201eda295e9a86a3 100644 (file)
@@ -17,6 +17,7 @@ import pyclbr
 import PyShell
 from WindowList import ListedToplevel
 from TreeWidget import TreeNode, TreeItem, ScrolledCanvas
+from configHandler import idleConf
 
 class ClassBrowser:
 
@@ -42,7 +43,9 @@ class ClassBrowser:
         self.settitle()
         top.focus_set()
         # create scrolled canvas
-        sc = ScrolledCanvas(top, bg="white", highlightthickness=0, takefocus=1)
+        theme = idleConf.GetOption('main','Theme','name')
+        background = idleConf.GetHighlight(theme, 'normal')['background']
+        sc = ScrolledCanvas(top, bg=background, highlightthickness=0, takefocus=1)
         sc.frame.pack(expand=1, fill="both")
         item = self.rootnode()
         self.node = node = TreeNode(sc.canvas, None, item)
index 7b7be228cc781e90acf2750e9a6e88a068c8cb39..250ca94905e09e5f27220a436ef5427f66dd1830 100644 (file)
@@ -1,6 +1,7 @@
 import time
 import re
 import keyword
+import __builtin__
 from Tkinter import *
 from Delegator import Delegator
 from configHandler import idleConf
@@ -17,13 +18,16 @@ def any(name, list):
 
 def make_pat():
     kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b"
+    builtinlist = [str(name) for name in dir(__builtin__)
+                                        if not name.startswith('_')]
+    builtin = r"([^\\.]\b|^)" + any("BUILTIN", builtinlist) + r"\b"
     comment = any("COMMENT", [r"#[^\n]*"])
     sqstring = r"(\b[rR])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
     dqstring = r'(\b[rR])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
     sq3string = r"(\b[rR])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
     dq3string = r'(\b[rR])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
     string = any("STRING", [sq3string, dq3string, sqstring, dqstring])
-    return kw + "|" + comment + "|" + string + "|" + any("SYNC", [r"\n"])
+    return kw + "|" + builtin + "|" + comment + "|" + string + "|" + any("SYNC", [r"\n"])
 
 prog = re.compile(make_pat(), re.S)
 idprog = re.compile(r"\s+(\w+)", re.S)
@@ -58,6 +62,7 @@ class ColorDelegator(Delegator):
         self.tagdefs = {
             "COMMENT": idleConf.GetHighlight(theme, "comment"),
             "KEYWORD": idleConf.GetHighlight(theme, "keyword"),
+            "BUILTIN": idleConf.GetHighlight(theme, "builtin"),
             "STRING": idleConf.GetHighlight(theme, "string"),
             "DEFINITION": idleConf.GetHighlight(theme, "definition"),
             "SYNC": {'background':None,'foreground':None},
@@ -68,7 +73,7 @@ class ColorDelegator(Delegator):
             "hit": idleConf.GetHighlight(theme, "hit"),
             }
 
-    if DEBUG: print 'tagdefs',tagdefs
+        if DEBUG: print 'tagdefs',self.tagdefs
 
     def insert(self, index, chars, tags=None):
         index = self.index(index)
index 65ffe54afdf9127eaaf20532af0fda30ffa7f900..546fa9d026c0ad31e9cb3c6d79219512b4241378 100644 (file)
@@ -510,6 +510,8 @@ class EditorWindow:
         if self.color:
             self.color = self.ColorDelegator()
             self.per.insertfilter(self.color)
+        theme = idleConf.GetOption('main','Theme','name')
+        self.text.config(idleConf.GetHighlight(theme, "normal"))
 
     def ResetFont(self):
         "Update the text widgets' font if it is changed"
index e2d4fc0c93505a0d777f4de4d397a232e6288f55..2ee12430444d0efa21ab3921c7dc1fb94710de56 100644 (file)
@@ -3,6 +3,8 @@ What's New in IDLE 1.1a0?
 
 *Release date: XX-XXX-2004*
 
+- Add a highlight theme for builtin keywords.  Python Patch 805830 Nigel Rowe
+
 - rpc.py:SocketIO - Large modules were generating large pickles when downloaded
   to the execution server.  The return of the OK response from the subprocess
   initialization was interfering and causing the sending socket to be not
index c619b7fce70cc2382652030eb421d7371846f308..028e3ee0ea097611b122fb62713eda1aa2fae87b 100644 (file)
@@ -528,7 +528,9 @@ class ModifiedInterpreter(InteractiveInterpreter):
         item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid)
         from TreeWidget import ScrolledCanvas, TreeNode
         top = Toplevel(self.tkconsole.root)
-        sc = ScrolledCanvas(top, bg="white", highlightthickness=0)
+        theme = idleConf.GetOption('main','Theme','name')
+        background = idleConf.GetHighlight(theme, 'normal')['background']
+        sc = ScrolledCanvas(top, bg=background, highlightthickness=0)
         sc.frame.pack(expand=1, fill="both")
         node = TreeNode(sc.canvas, None, item)
         node.expand()
index 1c9eb2ef1414c49db3c66e6ad576251b055ba476..c5c171fb83c2c67f7884b9cf0eb6efff50075175 100644 (file)
@@ -20,6 +20,7 @@ from Tkinter import *
 import imp
 
 import ZoomHeight
+from configHandler import idleConf
 
 ICONDIR = "Icons"
 
@@ -249,10 +250,11 @@ class TreeNode:
         except AttributeError:
             # padding carefully selected (on Windows) to match Entry widget:
             self.label = Label(self.canvas, text=text, bd=0, padx=2, pady=2)
+        theme = idleConf.GetOption('main','Theme','name')
         if self.selected:
-            self.label.configure(fg="white", bg="darkblue")
+            self.label.configure(idleConf.GetHighlight(theme, 'hilite'))
         else:
-            self.label.configure(fg="black", bg="white")
+            self.label.configure(idleConf.GetHighlight(theme, 'normal'))
         id = self.canvas.create_window(textx, texty,
                                        anchor="nw", window=self.label)
         self.label.bind("<1>", self.select_or_edit)
index b4991c6c6072eb5d6a0a051f5919cc7622c5a78b..f7eca5c670c2ca1a81351d8e687926ffe26e8f3a 100644 (file)
@@ -6,6 +6,8 @@ normal-foreground= #000000
 normal-background= #ffffff
 keyword-foreground= #ff7700
 keyword-background= #ffffff
+builtin-foreground= #ca00ca
+builtin-background= #ffffff
 comment-foreground= #dd0000
 comment-background= #ffffff
 string-foreground= #00aa00
@@ -35,6 +37,8 @@ normal-foreground= #000000
 normal-background= #ffffff
 keyword-foreground= #ff7700
 keyword-background= #ffffff
+builtin-foreground= #ca00ca
+builtin-background= #ffffff
 comment-foreground= #dd0000
 comment-background= #ffffff
 string-foreground= #00aa00
index 4e4e564cb64350973ccb2abc54859d112fc089ed..69cf818b01a57686a7e3924b41c50a9c65517dd0 100644 (file)
@@ -35,15 +35,17 @@ class ConfigDialog(Toplevel):
         self.themeElements={'Normal Text':('normal','00'),
             'Python Keywords':('keyword','01'),
             'Python Definitions':('definition','02'),
-            'Python Comments':('comment','03'),
-            'Python Strings':('string','04'),
-            'Selected Text':('hilite','05'),
-            'Found Text':('hit','06'),
-            'Cursor':('cursor','07'),
-            'Error Text':('error','08'),
-            'Shell Normal Text':('console','09'),
-            'Shell Stdout Text':('stdout','10'),
-            'Shell Stderr Text':('stderr','11')}
+            'Python Builtins':('builtin', '03'),
+            'Python Comments':('comment','04'),
+            'Python Strings':('string','05'),
+            'Selected Text':('hilite','06'),
+            'Found Text':('hit','07'),
+            'Cursor':('cursor','08'),
+            'Error Text':('error','09'),
+            'Shell Normal Text':('console','10'),
+            'Shell Stdout Text':('stdout','11'),
+            'Shell Stderr Text':('stderr','12'),
+            }
         self.ResetChangedItems() #load initial values in changed items dict
         self.CreateWidgets()
         self.resizable(height=FALSE,width=FALSE)
@@ -197,7 +199,9 @@ class ConfigDialog(Toplevel):
             (' ','normal'),('func','definition'),('(param):','normal'),
             ('\n  ','normal'),('"""string"""','string'),('\n  var0 = ','normal'),
             ("'string'",'string'),('\n  var1 = ','normal'),("'selected'",'hilite'),
-            ('\n  var2 = ','normal'),("'found'",'hit'),('\n\n','normal'),
+            ('\n  var2 = ','normal'),("'found'",'hit'),
+            ('\n  var3 = ','normal'),('list', 'builtin'), ('(','normal'),
+            ('None', 'builtin'),(')\n\n','normal'),
             (' error ','error'),(' ','normal'),('cursor |','cursor'),
             ('\n ','normal'),('shell','console'),(' ','normal'),('stdout','stdout'),
             (' ','normal'),('stderr','stderr'),('\n','normal'))
index d1c2b3c5f849c550312a7517411d71e2200e4fa3..e0b1612c3a5fa305ca658a302c2e9e6f589edb8b 100644 (file)
@@ -306,6 +306,8 @@ class IdleConf:
                 'normal-background':'#ffffff',
                 'keyword-foreground':'#000000',
                 'keyword-background':'#ffffff',
+                'builtin-foreground':'#000000',
+                'builtin-background':'#ffffff',
                 'comment-foreground':'#000000',
                 'comment-background':'#ffffff',
                 'string-foreground':'#000000',