aboutsummaryrefslogtreecommitdiff
path: root/input-keys.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2016-02-19 13:14:17 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2016-02-19 13:14:17 +0000
commitacc1090e778090b8c5d2488220897873266dc368 (patch)
tree861af8b648615a979ffe91dfbb64c0ca75f74658 /input-keys.c
parentfc864529f587fc4c913d1ad40da41eab2e512521 (diff)
downloadrtmux-acc1090e778090b8c5d2488220897873266dc368.tar.gz
rtmux-acc1090e778090b8c5d2488220897873266dc368.tar.bz2
rtmux-acc1090e778090b8c5d2488220897873266dc368.zip
Use system wcwidth() instead of carrying around UTF-8 width tables.
Diffstat (limited to 'input-keys.c')
-rw-r--r--input-keys.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/input-keys.c b/input-keys.c
index 9a39ba7c..2a22b089 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)
@@ -250,9 +263,9 @@ input_key_mouse(struct window_pane *wp, struct mouse_event *m)
m->sgr_b, x + 1, y + 1, m->sgr_type);
} else if (wp->screen->mode & MODE_MOUSE_UTF8) {
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;