[Python-checkins] cpython (2.7): #14146: Highlight source line while debugging on Windows.

roger.serwy python-checkins at python.org
Tue May 21 05:18:02 CEST 2013


http://hg.python.org/cpython/rev/5ae830ff6d64
changeset:   83876:5ae830ff6d64
branch:      2.7
parent:      83869:7937f5c56924
user:        Roger Serwy <roger.serwy at gmail.com>
date:        Mon May 20 22:13:39 2013 -0500
summary:
  #14146: Highlight source line while debugging on Windows.

files:
  Lib/idlelib/EditorWindow.py |  30 +++++++++++++++++++++++++
  Misc/NEWS                   |   6 +++++
  2 files changed, 36 insertions(+), 0 deletions(-)


diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -346,6 +346,36 @@
         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:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -21,6 +21,12 @@
 
 - Fix typos in the multiprocessing module.
 
+IDLE
+----
+
+- Issue #14146: Highlight source line while debugging on Windows.
+
+
 Tests
 -----
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list