Terry J. Reedy added the comment:
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='')
else:
print(r'\\U%08x' % ord(ss), end='')
# prints
X\\U00011111Y\\U00011112\\U00011113Z
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).]
----------
nosy: +terry.reedy
resolution: duplicate ->
versions: +Python 3.6 -Python 2.7, Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue21084>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com