This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients BreamoreBoy, THRlWiTi, ezio.melotti, malin, serhiy.storchaka, terry.reedy, vstinner
Date 2016-05-26.16:07:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Tk Text (and other widgets, but Text is the main issue) has two display problems: astral chars and long lines (over a thousand chars, say).  These problems can manifest in various places: file names, shell input (keyboard or clipboard), shell output, editor input (keyboard, clipboard, or file).  IDLE needs to take more control over what is displayed to work around both problems.

Tk Text also has a display feature: substring tagging.  I have been heistant to simple replace astral chars with their \U000hhhhh expansion because of the aliasing problem: in shell output, for instance, the user would not know if the program wrote 1 char or 10.  It would also be impossible to know if a reverse transformation might be needed.  Tagging astral expansions would solve both problems.

import re

astral = re.compile(r'([^\x00-\uffff])')
s = 'X\U00011111Y\U00011112\U00011113Z'
for i, ss in enumerate(re.split(astral, s)):
    if not i%2:
        print(ss, end='')
        print(r'\\U%08x' % ord(ss), end='')
# prints

Now replace print with test.insert, with an 'astral' tag for the second.  tk will not double '\'s.  Astral tag could switch, for instance, to underline version of current font.  This should work with any color scheme.

[Separate but related issue: augment Format or context menu with functions to convert between literal char, escape string, and name representation (using unicodedatabase).]
Date User Action Args
2016-05-26 16:07:45terry.reedysetrecipients: + terry.reedy, vstinner, ezio.melotti, THRlWiTi, BreamoreBoy, serhiy.storchaka, malin
2016-05-26 16:07:45terry.reedysetmessageid: <>
2016-05-26 16:07:45terry.reedylinkissue21084 messages
2016-05-26 16:07:45terry.reedycreate