Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit caf3024

Browse files
committed
#14146: Highlight source line while debugging on Windows.
1 parent bfc8f26 commit caf3024

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lib/idlelib/EditorWindow.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,36 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
340340
self.askinteger = tkSimpleDialog.askinteger
341341
self.showerror = tkMessageBox.showerror
342342

343+
self._highlight_workaround() # Fix selection tags on Windows
344+
345+
def _highlight_workaround(self):
346+
# On Windows, Tk removes painting of the selection
347+
# tags which is different behavior than on Linux and Mac.
348+
# See issue14146 for more information.
349+
if not sys.platform.startswith('win'):
350+
return
351+
352+
text = self.text
353+
text.event_add("<<Highlight-FocusOut>>", "<FocusOut>")
354+
text.event_add("<<Highlight-FocusIn>>", "<FocusIn>")
355+
def highlight_fix(focus):
356+
sel_range = text.tag_ranges("sel")
357+
if sel_range:
358+
if focus == 'out':
359+
HILITE_CONFIG = idleConf.GetHighlight(
360+
idleConf.CurrentTheme(), 'hilite')
361+
text.tag_config("sel_fix", HILITE_CONFIG)
362+
text.tag_raise("sel_fix")
363+
text.tag_add("sel_fix", *sel_range)
364+
elif focus == 'in':
365+
text.tag_remove("sel_fix", "1.0", "end")
366+
367+
text.bind("<<Highlight-FocusOut>>",
368+
lambda ev: highlight_fix("out"))
369+
text.bind("<<Highlight-FocusIn>>",
370+
lambda ev: highlight_fix("in"))
371+
372+
343373
def _filename_to_unicode(self, filename):
344374
"""convert filename to unicode in order to display it in Tk"""
345375
if isinstance(filename, str) or not filename:

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ Library
3737

3838
- Issue #17968: Fix memory leak in os.listxattr().
3939

40+
IDLE
41+
----
42+
43+
- Issue #14146: Highlight source line while debugging on Windows.
44+
45+
4046
Tests
4147
-----
4248

0 commit comments

Comments
 (0)