]> granicus.if.org Git - python/commitdiff
#14146: Highlight source line while debugging on Windows.
authorRoger Serwy <roger.serwy@gmail.com>
Tue, 21 May 2013 03:13:39 +0000 (22:13 -0500)
committerRoger Serwy <roger.serwy@gmail.com>
Tue, 21 May 2013 03:13:39 +0000 (22:13 -0500)
Lib/idlelib/EditorWindow.py
Misc/NEWS

index 27c989cb117e0d0869b3f0c250cba3328e3345f7..fdcf1a051bee31d60deb3588165041ed26fea460 100644 (file)
@@ -340,6 +340,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, str) or not filename:
index 5d9494781fe3963a755df8c4cf88c394947327f1..9f21947ceea71e7a67f2a6889afd417fe3753565 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,12 @@ Library
 
 - Issue #17968: Fix memory leak in os.listxattr().
 
+IDLE
+----
+
+- Issue #14146: Highlight source line while debugging on Windows.
+
+
 Tests
 -----