summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2004-03-08 18:15:31 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2004-03-08 18:15:31 (GMT)
commit73360a3e61274ffcc4c9fc3d09746bd6603e92a5 (patch)
tree261894a40d78f78641cf21f4f16af44e5411cf07 /Lib/idlelib
parent4102478f46c7b419c15b783643539801aaabb6a6 (diff)
downloadcpython-73360a3e61274ffcc4c9fc3d09746bd6603e92a5.zip
cpython-73360a3e61274ffcc4c9fc3d09746bd6603e92a5.tar.gz
cpython-73360a3e61274ffcc4c9fc3d09746bd6603e92a5.tar.bz2
Add a highlight theme for builtin keywords. Python Patch 805830 Nigel Rowe
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
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/ClassBrowser.py5
-rw-r--r--Lib/idlelib/ColorDelegator.py9
-rw-r--r--Lib/idlelib/EditorWindow.py2
-rw-r--r--Lib/idlelib/NEWS.txt2
-rw-r--r--Lib/idlelib/PyShell.py4
-rw-r--r--Lib/idlelib/TreeWidget.py6
-rw-r--r--Lib/idlelib/config-highlight.def4
-rw-r--r--Lib/idlelib/configDialog.py24
-rw-r--r--Lib/idlelib/configHandler.py2
9 files changed, 42 insertions, 16 deletions
diff --git a/Lib/idlelib/ClassBrowser.py b/Lib/idlelib/ClassBrowser.py
index 82f5191..e5a60a5 100644
--- a/Lib/idlelib/ClassBrowser.py
+++ b/Lib/idlelib/ClassBrowser.py
@@ -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)
diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py
index 7b7be22..250ca94 100644
--- a/Lib/idlelib/ColorDelegator.py
+++ b/Lib/idlelib/ColorDelegator.py
@@ -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)
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index 65ffe54..546fa9d 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -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"
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index e2d4fc0..2ee1243 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -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
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index c619b7f..028e3ee 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -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()
diff --git a/Lib/idlelib/TreeWidget.py b/Lib/idlelib/TreeWidget.py
index 1c9eb2e..c5c171f 100644
--- a/Lib/idlelib/TreeWidget.py
+++ b/Lib/idlelib/TreeWidget.py
@@ -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)
diff --git a/Lib/idlelib/config-highlight.def b/Lib/idlelib/config-highlight.def
index b4991c6..f7eca5c 100644
--- a/Lib/idlelib/config-highlight.def
+++ b/Lib/idlelib/config-highlight.def
@@ -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
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index 4e4e564..69cf818 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -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'))
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
index d1c2b3c..e0b1612 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -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',