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 /Lib/idlelib/EditorWindow.py | |
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.
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 59 |
1 files changed, 26 insertions, 33 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" |