diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2015-09-28 02:50:54 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2015-09-28 02:50:54 (GMT) |
commit | 2122b62c2aa69886b76bb0c68fbce48afae59d0f (patch) | |
tree | 9b0383fafe72ae0ea91bded40465ab0112d0f414 /Lib/idlelib/EditorWindow.py | |
parent | 7082cbce64818f66ae9b493a0cbeb2c5d0c25e32 (diff) | |
download | cpython-2122b62c2aa69886b76bb0c68fbce48afae59d0f.zip cpython-2122b62c2aa69886b76bb0c68fbce48afae59d0f.tar.gz cpython-2122b62c2aa69886b76bb0c68fbce48afae59d0f.tar.bz2 |
Backed out changeset: 70c01dd35100
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index d742dd6..74a4749 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -317,6 +317,36 @@ class EditorWindow(object): self.askinteger = tkSimpleDialog.askinteger self.showerror = tkMessageBox.showerror + self._highlight_workaround() # Fix selection tags on Windows + + def _highlight_workaround(self): + # On Windows, Tk removes painting of the selection + # tags which is different behavior than on Linux and Mac. + # See issue14146 for more information. + if not sys.platform.startswith('win'): + return + + text = self.text + text.event_add("<<Highlight-FocusOut>>", "<FocusOut>") + text.event_add("<<Highlight-FocusIn>>", "<FocusIn>") + def highlight_fix(focus): + sel_range = text.tag_ranges("sel") + if sel_range: + if focus == 'out': + HILITE_CONFIG = idleConf.GetHighlight( + idleConf.CurrentTheme(), 'hilite') + text.tag_config("sel_fix", HILITE_CONFIG) + text.tag_raise("sel_fix") + text.tag_add("sel_fix", *sel_range) + elif focus == 'in': + text.tag_remove("sel_fix", "1.0", "end") + + text.bind("<<Highlight-FocusOut>>", + lambda ev: highlight_fix("out")) + text.bind("<<Highlight-FocusIn>>", + lambda ev: highlight_fix("in")) + + def _filename_to_unicode(self, filename): """Return filename as BMP unicode so diplayable in Tk.""" # Decode bytes to unicode. @@ -755,7 +785,6 @@ class EditorWindow(object): insertbackground=cursor_color, selectforeground=select_colors['foreground'], selectbackground=select_colors['background'], - inactiveselectbackground=select_colors['background'], ) IDENTCHARS = string.ascii_letters + string.digits + "_" |