TIP 588: Unicode for (X11) keysyms

Login
Author:         Jan Nijtmans <[email protected]>
State:          Final
Type:           Project
Vote:           Done
Created:        23-Oct-2020
Post-History:
Keywords:       X11
Tcl-Version:    8.7
Tk-Branch:	keysym-unicode
Vote-Summary:   Accepted 6/0/0
Votes-For:      DKF, FV, JN, KBK, KW, SL
Votes-Against:  none
Votes-Present:  none

Abstract

This TIP proposes to allow Unicode characters in X11 keysyms.

Rationale

In Tk 8.6, the list of supported keysyms is based on X11R5. In Tk 8.7, this list is upgraded to X11R6. This makes the keysym table a lot larger. The file "keysymdef.h" in Tk 8.6 has 1003 #define's, the same file in Tk 8.7 currently has 2109 #define's, that's more than doubled.

Many of those keysyms have an value which is just 0x1000000 more than the Unicode symbol entry, e.g.:

#define XK_Armenian_ligature_ew       0x1000587  /* U+0587 ARMENIAN SMALL LIGATURE ECH YIWN */

Specification

In all places where X11 keysyms are allowed, Tk will now allow the Unicode character directly. Example:

    bind .text <colon> {puts colon}
    bind .text <EuroSign> {puts pingping}
    bind .text <Armenian_ligature_ew> {puts hello}

can now be written directly as:

    bind .text <:> {puts colon}
    bind .text <€> {puts pingping}
    bind .text <և> {puts hello}

All entries in the keysym table which are new in X11R6 and have a keysym number which is 0x1000000 more than the Unicode symbol entry, are removed from Tk's keysym table. They only can be accessed in the "bind" command using the Unicode character directly. This reduces the keysym table from 2109 back to only 1343 entries.

All entries in the keysym table which already existed in X11R5 but having the same relation with the Unicode symbol entry, will be deprecated.

All entries in the ascii and latin range (between 0x21 and 0xFF) and which are printable (so no "space" and "nobreakspace") and don't conflict with the binding syntax (so no "greater" and "minus") and don't have other special meaning in Tcl (so no "backslash" and "semicolon") will be deprecated in its long form.

Further on, there are a number of synonymes in the binding specification, which are only possibly confusing people: e.g. <M> is equivalent to <Meta>, <KeyPress> is equivalent to <Key> and <ButtonPress> is equivalent to <Button>. This TIP proposes to deprecate the <M>, <KeyPress> and <ButtonPress> forms.

If Tk is compiled with -DTK_NO_DEPRECATED, all forms declared deprecated will be actually unavailable. This can be used to test your scripts, whether they actually still use deprecated features. But this compile flag is not recommended to be used in production.

Compatibility

This is fully upwards compatible with Tk 8.6, but not with Tk 8.7a3.

Reference Implementation

In tk branch keysym-unicode

Copyright

This document has been placed in the public domain.