diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-01 13:21:49 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-01 13:21:49 (GMT) |
commit | 9396498c5f86cb4cf444bdb3c2cbe907b5495e0f (patch) | |
tree | f277aed8334f7eb42ec11d0dea0c75d747cd0cde /win/tkWinKey.c | |
parent | a31e2babe597336a3c0c0dce7a3ebb8686c7e1e0 (diff) | |
download | tk-9396498c5f86cb4cf444bdb3c2cbe907b5495e0f.zip tk-9396498c5f86cb4cf444bdb3c2cbe907b5495e0f.tar.gz tk-9396498c5f86cb4cf444bdb3c2cbe907b5495e0f.tar.bz2 |
(experiment) don't fill trans_chars any more when send_event == -3. Results in many simplifications while it still should work the same
Diffstat (limited to 'win/tkWinKey.c')
-rw-r--r-- | win/tkWinKey.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/win/tkWinKey.c b/win/tkWinKey.c index a49898f..64f8cd4 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -113,15 +113,18 @@ TkpGetString( Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { + + char buf[XMaxTransChars]; + int len; + /* - * Special case for WM_UNICHAR. xkey.trans_chars[] already contains a - * UTF-8 char, except when nbytes == 0 (then it didn't fit there). + * Special case for WM_UNICHAR. */ - if (keyEv->nbytes) { - Tcl_DStringAppend(dsPtr, keyEv->trans_chars, keyEv->nbytes); - } else if (keyEv->keycode > 0xffff) { - char buf[XMaxTransChars]; + len = Tcl_UniCharToUtf(keyEv->keycode, buf); + if ((keyEv->keycode <= 0xffff) || (len == XMaxTransChars)) { + Tcl_DStringAppend(dsPtr, buf, len); + } else { Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf); Tcl_DStringAppend(dsPtr, buf, 3); Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) & 0x3ff) | 0xdc00, buf); |