summaryrefslogtreecommitdiffstats
path: root/input-keys.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2015-11-12 12:01:17 +0000
committerThomas Adam <thomas@xteddy.org>2015-11-12 12:01:17 +0000
commit5f483499f3a7b98da9ac67cd62ed91034a5949ed (patch)
treede84187f104010233d96acc68bb9cc91d173c243 /input-keys.c
parent333da3b64b4ce8c0343f082c3923473205ab2b27 (diff)
parent0cc812ae342d1a71c0337db8ffb4d7701668cb38 (diff)
Merge branch 'obsd-master'
Diffstat (limited to 'input-keys.c')
-rw-r--r--input-keys.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/input-keys.c b/input-keys.c
index f629dd5b..160d58da 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -33,7 +33,7 @@
void input_key_mouse(struct window_pane *, struct mouse_event *);
struct input_key_ent {
- int key;
+ key_code key;
const char *data;
int flags;
@@ -136,15 +136,16 @@ const struct input_key_ent input_keys[] = {
/* Translate a key code into an output key sequence. */
void
-input_key(struct window_pane *wp, int key, struct mouse_event *m)
+input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
{
- const struct input_key_ent *ike;
- u_int i;
- size_t dlen;
- char *out;
- u_char ch;
+ const struct input_key_ent *ike;
+ u_int i;
+ size_t dlen;
+ char *out;
+ key_code justkey;
+ struct utf8_data utf8data;
- log_debug("writing key 0x%x (%s) to %%%u", key,
+ log_debug("writing key 0x%llx (%s) to %%%u", key,
key_string_lookup_key(key), wp->id);
/* If this is a mouse key, pass off to mouse function. */
@@ -156,13 +157,22 @@ input_key(struct window_pane *wp, int key, struct mouse_event *m)
/*
* If this is a normal 7-bit key, just send it, with a leading escape
- * if necessary.
+ * if necessary. If it is a UTF-8 key, split it and send it.
*/
- if (key != KEYC_NONE && (key & ~KEYC_ESCAPE) < 0x100) {
+ justkey = (key & ~KEYC_ESCAPE);
+ if (key != KEYC_NONE && justkey < 0x7f) {
if (key & KEYC_ESCAPE)
bufferevent_write(wp->event, "\033", 1);
- ch = key & ~KEYC_ESCAPE;
- bufferevent_write(wp->event, &ch, 1);
+ utf8data.data[0] = justkey;
+ bufferevent_write(wp->event, &utf8data.data[0], 1);
+ return;
+ }
+ if (key != KEYC_NONE && justkey > 0x7f && justkey < KEYC_BASE) {
+ if (utf8_split(justkey, &utf8data) != 0)
+ return;
+ if (key & KEYC_ESCAPE)
+ bufferevent_write(wp->event, "\033", 1);
+ bufferevent_write(wp->event, utf8data.data, utf8data.size);
return;
}
@@ -195,11 +205,11 @@ input_key(struct window_pane *wp, int key, struct mouse_event *m)
break;
}
if (i == nitems(input_keys)) {
- log_debug("key 0x%x missing", key);
+ log_debug("key 0x%llx missing", key);
return;
}
dlen = strlen(ike->data);
- log_debug("found key 0x%x: \"%s\"", key, ike->data);
+ log_debug("found key 0x%llx: \"%s\"", key, ike->data);
/* Prefix a \033 for escape. */
if (key & KEYC_ESCAPE)