diff options
author | Roger Serwy <roger.serwy@gmail.com> | 2013-05-21 03:13:39 (GMT) |
---|---|---|
committer | Roger Serwy <roger.serwy@gmail.com> | 2013-05-21 03:13:39 (GMT) |
commit | 02c0ed06123d62dcf4c686e0f5bc48bac55676cc (patch) | |
tree | 2bf9f5a98de08cb85c7b8ea7a7a78a267725080e /Lib/idlelib | |
parent | d7cb506789a8003cd707343a43cd6b0595a99606 (diff) | |
download | cpython-02c0ed06123d62dcf4c686e0f5bc48bac55676cc.zip cpython-02c0ed06123d62dcf4c686e0f5bc48bac55676cc.tar.gz cpython-02c0ed06123d62dcf4c686e0f5bc48bac55676cc.tar.bz2 |
#14146: Highlight source line while debugging on Windows.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index cf3fad3..38cbfcf 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -346,6 +346,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): """convert filename to unicode in order to display it in Tk""" if isinstance(filename, unicode) or not filename: |