version 1.45, 2015/10/27 15:58:42 |
version 1.46, 2015/11/12 11:05:34 |
|
|
void input_key_mouse(struct window_pane *, struct mouse_event *); |
void input_key_mouse(struct window_pane *, struct mouse_event *); |
|
|
struct input_key_ent { |
struct input_key_ent { |
int key; |
key_code key; |
const char *data; |
const char *data; |
|
|
int flags; |
int flags; |
|
|
|
|
/* Translate a key code into an output key sequence. */ |
/* Translate a key code into an output key sequence. */ |
void |
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; |
const struct input_key_ent *ike; |
u_int i; |
u_int i; |
size_t dlen; |
size_t dlen; |
char *out; |
char *out; |
u_char ch; |
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); |
key_string_lookup_key(key), wp->id); |
|
|
/* If this is a mouse key, pass off to mouse function. */ |
/* If this is a mouse key, pass off to mouse function. */ |
|
|
|
|
/* |
/* |
* If this is a normal 7-bit key, just send it, with a leading escape |
* 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) |
if (key & KEYC_ESCAPE) |
bufferevent_write(wp->event, "\033", 1); |
bufferevent_write(wp->event, "\033", 1); |
ch = key & ~KEYC_ESCAPE; |
utf8data.data[0] = justkey; |
bufferevent_write(wp->event, &ch, 1); |
bufferevent_write(wp->event, &utf8data.data[0], 1); |
return; |
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; |
|
} |
|
|
/* |
/* |
* Then try to look this up as an xterm key, if the flag to output them |
* Then try to look this up as an xterm key, if the flag to output them |
|
|
break; |
break; |
} |
} |
if (i == nitems(input_keys)) { |
if (i == nitems(input_keys)) { |
log_debug("key 0x%x missing", key); |
log_debug("key 0x%llx missing", key); |
return; |
return; |
} |
} |
dlen = strlen(ike->data); |
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. */ |
/* Prefix a \033 for escape. */ |
if (key & KEYC_ESCAPE) |
if (key & KEYC_ESCAPE) |