diff options
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 55 | ||||
-rw-r--r-- | Lib/idlelib/NEWS.txt | 6 | ||||
-rw-r--r-- | Lib/idlelib/ScriptBinding.py | 13 | ||||
-rw-r--r-- | Lib/idlelib/configDialog.py | 3 |
4 files changed, 39 insertions, 38 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index 0cd668abf8a..e1d9ba3256f 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -109,16 +109,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 @@ -225,7 +215,6 @@ class EditorWindow(object): # Making the initial values larger slows things down more often. self.num_context_lines = 50, 500, 5000000 self.per = per = self.Percolator(text) - self.color = None self.undo = undo = self.UndoDelegator() per.insertfilter(undo) text.undo_block_start = undo.undo_block_start @@ -236,6 +225,7 @@ class EditorWindow(object): io.set_filename_change_hook(self.filename_change_hook) self.good_load = False self.set_indentation_params(False) + self.color = None # initialized below in self.ResetColorizer if filename: if os.path.exists(filename) and not os.path.isdir(filename): if io.loadfile(filename): @@ -247,6 +237,7 @@ class EditorWindow(object): per.insertfilter(color) else: io.set_filename(filename) + self.ResetColorizer() self.saved_change_hook() self.update_recent_files_list() self.load_extensions() @@ -561,36 +552,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'], + ) IDENTCHARS = string.ascii_letters + string.digits + "_" diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index cd8565ce167..1885421d576 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -45,6 +45,12 @@ What's New in IDLE 2.6a1? *Release date: XX-XXX-200X* UNRELEASED, but merged into 3.0 +- 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. - Could not open files in .idlerc directory if latter was hidden on Windows. diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py index ae530e5fa85..226c66ce34a 100644 --- a/Lib/idlelib/ScriptBinding.py +++ b/Lib/idlelib/ScriptBinding.py @@ -55,11 +55,11 @@ class ScriptBinding: def check_module_event(self, event): filename = self.getfilename() if not filename: - return + return 'break' if not self.checksyntax(filename): - return + return 'break' if not self.tabnanny(filename): - return + return 'break' def tabnanny(self, filename): f = open(filename, 'r') @@ -120,12 +120,12 @@ class ScriptBinding: """ filename = self.getfilename() if not filename: - return + return 'break' code = self.checksyntax(filename) if not code: - return + return 'break' if not self.tabnanny(filename): - return + return 'break' shell = self.shell interp = shell.interp if PyShell.use_subprocess: @@ -148,6 +148,7 @@ class ScriptBinding: # go to __stderr__. With subprocess, they go to the shell. # Need to change streams in PyShell.ModifiedInterpreter. interp.runcode(code) + return 'break' def getfilename(self): """Get source filename. If not saved, offer to save (or create) file diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py index d0e4066b295..b750dcd5767 100644 --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configDialog.py @@ -1114,15 +1114,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() |