diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-26 11:45:14 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-26 11:45:14 (GMT) |
commit | 6fc7c3942a4f1f84b585a5570818f98299254c51 (patch) | |
tree | 3d5fa836f5a3c3ea017592b62ab7f54bdcb87724 /win | |
parent | 05a224b57c876cd9db9d2478dddf9614b16b0661 (diff) | |
download | tk-6fc7c3942a4f1f84b585a5570818f98299254c51.zip tk-6fc7c3942a4f1f84b585a5570818f98299254c51.tar.gz tk-6fc7c3942a4f1f84b585a5570818f98299254c51.tar.bz2 |
Introduce two utility functions for handling Unicode surrogate pairs, and use it in tkWinKey.c. No change in functionality.
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinKey.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 2698c4d..a567653 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -88,6 +88,8 @@ TkpGetString( * result. */ { XKeyEvent *keyEv = &eventPtr->xkey; + char buf[6]; + int len; Tcl_DStringInit(dsPtr); if (keyEv->send_event == -1) { @@ -102,8 +104,6 @@ TkpGetString( */ int unichar; - char buf[XMaxTransChars]; - int len; unichar = keyEv->trans_chars[1] & 0xff; unichar <<= 8; @@ -114,22 +114,12 @@ TkpGetString( Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { - char buf[XMaxTransChars]; - int len; - /* * Special case for WM_UNICHAR. */ - 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); - Tcl_DStringAppend(dsPtr, buf, 3); - } + len = TkUniCharToUtf(keyEv->keycode, buf); + Tcl_DStringAppend(dsPtr, buf, len); } else { /* * This is an event generated from generic code. It has no nchars or @@ -140,9 +130,6 @@ TkpGetString( if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256)) || (keysym == XK_Return) || (keysym == XK_Tab)) { - char buf[XMaxTransChars]; - int len; - len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf); Tcl_DStringAppend(dsPtr, buf, len); } |