diff options
author | Thomas Adam <thomas@xteddy.org> | 2016-03-02 18:10:51 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2016-03-02 18:10:51 +0000 |
commit | e304673c65d774bb76e5d55c095c8c8e6b05ff91 (patch) | |
tree | af461e71978b76dad59348d924a37f62b8c0bb7d /input-keys.c | |
parent | e9d369a09e48ea8f940958025c8444988d31e840 (diff) | |
parent | b8a102d26f41e57b94359627a4df8f22af10c6fa (diff) | |
download | rtmux-e304673c65d774bb76e5d55c095c8c8e6b05ff91.tar.gz rtmux-e304673c65d774bb76e5d55c095c8c8e6b05ff91.tar.bz2 rtmux-e304673c65d774bb76e5d55c095c8c8e6b05ff91.zip |
Merge branch 'obsd-master'
Conflicts:
utf8.c
Diffstat (limited to 'input-keys.c')
-rw-r--r-- | input-keys.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/input-keys.c b/input-keys.c index 9a39ba7c..9538e876 100644 --- a/input-keys.c +++ b/input-keys.c @@ -134,6 +134,19 @@ const struct input_key_ent input_keys[] = { { KEYC_KP_PERIOD, ".", 0 }, }; +/* Split a character into two UTF-8 bytes. */ +static size_t +input_split2(u_int c, u_char *dst) +{ + if (c > 0x7f) { + dst[0] = (c >> 6) | 0xc0; + dst[1] = (c & 0x3f) | 0x80; + return (2); + } + dst[0] = c; + return (1); +} + /* Translate a key code into an output key sequence. */ void input_key(struct window_pane *wp, key_code key, struct mouse_event *m) @@ -249,10 +262,12 @@ input_key_mouse(struct window_pane *wp, struct mouse_event *m) len = xsnprintf(buf, sizeof buf, "\033[<%u;%u;%u%c", m->sgr_b, x + 1, y + 1, m->sgr_type); } else if (wp->screen->mode & MODE_MOUSE_UTF8) { + if (m->b > 0x7ff - 32 || x > 0x7ff - 33 || y > 0x7ff - 33) + return; len = xsnprintf(buf, sizeof buf, "\033[M"); - len += utf8_split2(m->b + 32, &buf[len]); - len += utf8_split2(x + 33, &buf[len]); - len += utf8_split2(y + 33, &buf[len]); + len += input_split2(m->b + 32, &buf[len]); + len += input_split2(x + 33, &buf[len]); + len += input_split2(y + 33, &buf[len]); } else { if (m->b > 223) return; |