Author terry.reedy
Recipients BreamoreBoy, Ma Lin, THRlWiTi, ezio.melotti, serhiy.storchaka, terry.reedy, vstinner
Date 2016-05-26.16:07:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464278865.47.0.5835035296.issue21084@psf.upfronthosting.co.za>
In-reply-to
Content
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).]
History
Date User Action Args
2016-05-26 16:07:45terry.reedysetrecipients: + terry.reedy, vstinner, ezio.melotti, THRlWiTi, BreamoreBoy, serhiy.storchaka, Ma Lin
2016-05-26 16:07:45terry.reedysetmessageid: <1464278865.47.0.5835035296.issue21084@psf.upfronthosting.co.za>
2016-05-26 16:07:45terry.reedylinkissue21084 messages
2016-05-26 16:07:45terry.reedycreate