[Python-checkins] r60844 - python/trunk/Lib/idlelib/EditorWindow.py python/trunk/Lib/idlelib/NEWS.txt python/trunk/Lib/idlelib/configDialog.py

kurt.kaiser python-checkins at python.org
Fri Feb 15 23:25:09 CET 2008


Author: kurt.kaiser
Date: Fri Feb 15 23:25:09 2008
New Revision: 60844

Modified:
   python/trunk/Lib/idlelib/EditorWindow.py
   python/trunk/Lib/idlelib/NEWS.txt
   python/trunk/Lib/idlelib/configDialog.py
Log:
Configured selection highlighting colors were ignored; updating highlighting
in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator.  Patch 1334. Tal Einat.


Modified: python/trunk/Lib/idlelib/EditorWindow.py
==============================================================================
--- python/trunk/Lib/idlelib/EditorWindow.py	(original)
+++ python/trunk/Lib/idlelib/EditorWindow.py	Fri Feb 15 23:25:09 2008
@@ -107,16 +107,6 @@
         self.width = idleConf.GetOption('main','EditorWindow','width')
         self.text = text = MultiCallCreator(Text)(
                 text_frame, name='text', padx=5, wrap='none',
-                foreground=idleConf.GetHighlight(currentTheme,
-                        'normal',fgBg='fg'),
-                background=idleConf.GetHighlight(currentTheme,
-                        'normal',fgBg='bg'),
-                highlightcolor=idleConf.GetHighlight(currentTheme,
-                        'hilite',fgBg='fg'),
-                highlightbackground=idleConf.GetHighlight(currentTheme,
-                        'hilite',fgBg='bg'),
-                insertbackground=idleConf.GetHighlight(currentTheme,
-                        'cursor',fgBg='fg'),
                 width=self.width,
                 height=idleConf.GetOption('main','EditorWindow','height') )
         self.top.focused_widget = self.text
@@ -224,11 +214,6 @@
         self.num_context_lines = 50, 500, 5000000
 
         self.per = per = self.Percolator(text)
-        if self.ispythonsource(filename):
-            self.color = color = self.ColorDelegator()
-            per.insertfilter(color)
-        else:
-            self.color = None
 
         self.undo = undo = self.UndoDelegator()
         per.insertfilter(undo)
@@ -247,11 +232,13 @@
                                              menu=self.recent_files_menu)
         self.update_recent_files_list()
 
+        self.color = None # initialized below in self.ResetColorizer
         if filename:
             if os.path.exists(filename) and not os.path.isdir(filename):
                 io.loadfile(filename)
             else:
                 io.set_filename(filename)
+        self.ResetColorizer()
         self.saved_change_hook()
 
         self.set_indentation_params(self.ispythonsource(filename))
@@ -572,36 +559,42 @@
             self.flist.filename_changed_edit(self)
         self.saved_change_hook()
         self.top.update_windowlist_registry(self)
-        if self.ispythonsource(self.io.filename):
-            self.addcolorizer()
-        else:
-            self.rmcolorizer()
+        self.ResetColorizer()
 
-    def addcolorizer(self):
+    def _addcolorizer(self):
         if self.color:
             return
-        self.per.removefilter(self.undo)
-        self.color = self.ColorDelegator()
-        self.per.insertfilter(self.color)
-        self.per.insertfilter(self.undo)
+        if self.ispythonsource(self.io.filename):
+            self.color = self.ColorDelegator()
+        # can add more colorizers here...
+        if self.color:
+            self.per.removefilter(self.undo)
+            self.per.insertfilter(self.color)
+            self.per.insertfilter(self.undo)
 
-    def rmcolorizer(self):
+    def _rmcolorizer(self):
         if not self.color:
             return
         self.color.removecolors()
-        self.per.removefilter(self.undo)
         self.per.removefilter(self.color)
         self.color = None
-        self.per.insertfilter(self.undo)
 
     def ResetColorizer(self):
-        "Update the colour theme if it is changed"
-        # Called from configDialog.py
-        if self.color:
-            self.color = self.ColorDelegator()
-            self.per.insertfilter(self.color)
+        "Update the colour theme"
+        # Called from self.filename_change_hook and from configDialog.py
+        self._rmcolorizer()
+        self._addcolorizer()
         theme = idleConf.GetOption('main','Theme','name')
-        self.text.config(idleConf.GetHighlight(theme, "normal"))
+        normal_colors = idleConf.GetHighlight(theme, 'normal')
+        cursor_color = idleConf.GetHighlight(theme, 'cursor', fgBg='fg')
+        select_colors = idleConf.GetHighlight(theme, 'hilite')
+        self.text.config(
+            foreground=normal_colors['foreground'],
+            background=normal_colors['background'],
+            insertbackground=cursor_color,
+            selectforeground=select_colors['foreground'],
+            selectbackground=select_colors['background'],
+            )
 
     def ResetFont(self):
         "Update the text widgets' font if it is changed"

Modified: python/trunk/Lib/idlelib/NEWS.txt
==============================================================================
--- python/trunk/Lib/idlelib/NEWS.txt	(original)
+++ python/trunk/Lib/idlelib/NEWS.txt	Fri Feb 15 23:25:09 2008
@@ -3,6 +3,10 @@
 
 *Release date: XX-XXX-2008*
 
+- Configured selection highlighting colors were ignored; updating highlighting
+  in the config dialog would cause non-Python files to be colored as if they
+  were Python source; improve use of ColorDelagator.  Patch 1334. Tal Einat.
+
 - ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat.
 
 - There was an error on exit if no sys.exitfunc was defined. Issue 1647.

Modified: python/trunk/Lib/idlelib/configDialog.py
==============================================================================
--- python/trunk/Lib/idlelib/configDialog.py	(original)
+++ python/trunk/Lib/idlelib/configDialog.py	Fri Feb 15 23:25:09 2008
@@ -1119,15 +1119,12 @@
     def ActivateConfigChanges(self):
         "Dynamically apply configuration changes"
         winInstances=self.parent.instance_dict.keys()
-        theme = idleConf.CurrentTheme()
-        cursor_color = idleConf.GetHighlight(theme, 'cursor', fgBg='fg')
         for instance in winInstances:
             instance.ResetColorizer()
             instance.ResetFont()
             instance.set_notabs_indentwidth()
             instance.ApplyKeybindings()
             instance.reset_help_menu_entries()
-            instance.text.configure(insertbackground=cursor_color)
 
     def Cancel(self):
         self.destroy()


More information about the Python-checkins mailing list