diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2008-02-15 22:25:09 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2008-02-15 22:25:09 (GMT) |
commit | f05fa33a6c42bc21ffdfe7a20226a2b9a83ac3c2 (patch) | |
tree | 81a5d693f49e4b053c6ca3975bd99f170099a49c | |
parent | e312cfddd363a2ace2a8108927a610387f8e4a50 (diff) | |
download | cpython-f05fa33a6c42bc21ffdfe7a20226a2b9a83ac3c2.zip cpython-f05fa33a6c42bc21ffdfe7a20226a2b9a83ac3c2.tar.gz cpython-f05fa33a6c42bc21ffdfe7a20226a2b9a83ac3c2.tar.bz2 |
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.
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 59 | ||||
-rw-r--r-- | Lib/idlelib/NEWS.txt | 4 | ||||
-rw-r--r-- | Lib/idlelib/configDialog.py | 3 |
3 files changed, 30 insertions, 36 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index f95b1a6..b1c9734 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -107,16 +107,6 @@ class EditorWindow(object): 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 @@ class EditorWindow(object): 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 @@ class EditorWindow(object): 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 @@ class EditorWindow(object): 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" diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 5b0c012..81cbfb3 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -3,6 +3,10 @@ What's New in IDLE 2.6a1? *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. diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py index 8642fc9..010ab2c 100644 --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configDialog.py @@ -1119,15 +1119,12 @@ class ConfigDialog(Toplevel): 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() |