New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDLE: syntax highlighting and selected text #93266
Comments
Any thoughts? |
Currently selection is implemented not as an overlay (as other programs do) but as a comment-like range with its own background and foreground: Doing otherwise requires deep rewriting of grammar tree processing (after getting familiarized with all modules of IDLE). I suspect that currently there is nobody with enough free time to pull it out. However... @terryjreedy (as a maintainer of IDLE), @taleinat? |
@arhadthedev It had the highlighting stay in 3.9 so it's a recent change |
This issue duplicates https://stackoverflow.com/questions/72367529/idle-highlighted-text-loses-syntax-highlighting, open 2 days earlier. @Moosems, if you are the same person or read the SO question, this fact should have been indicated there and here. To expand on what I already said there: I don't believe that IDLE removes and restores syntax tags as selection is added and removed. Tk exposes selections as a special built-in undeletable tag. The standard behavior of tags is that the most recent tag wins. Thus the current behavior is exactly as I expect, with IDLE and tkinter having nothing to do with selections be added and removed by mouse and key action. To find out more, I experimented with 4 variations of 'raw' tkinter code.
A tag with both foreground and background configured can be selected (as in 'delete selection', ^X, deleting), but there is no visible indication of the extent of the selection. This, option A above, is not useful. A tag with only foreground configured changes background - option B. IDLE configures both for all tags. There is one IDLE tag that behaves like option A -- the checkpoint tag. All others, applied by the colorizer, act like option C -- selection overrides both fore and background. To make the example more like IDLE, I added the following, based on a statement in colorizer.py:
The result is that that tag_add no longer colors 'gregarious'. I cannot investigate more now. @arhadthedev I don't understand the relevance of grammar tree processing to colorizing. |
I am not sure if this is the right solution to this issue but I asked a 'similar' question in stack overflow recently here. The person who answered said to set the foreground of the text widget to "" which turned out to work for me. |
Bug report
In the newest version of python (Python3.10.4) IDLE will remove syntax highlighting on selected text. How do I remove this? Is there anything in the tkinter source code that I have to change on my ened?
Your environment
Images:
Before selection:
After selection:
Example of other IDE's (What IDLE used to do):
The text was updated successfully, but these errors were encountered: