diff options
author | Tiago Cunha <tcunha@gmx.com> | 2011-01-07 14:34:45 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2011-01-07 14:34:45 +0000 |
commit | 219442cff707a1febb6a75ba2cfe48b02ae0a22e (patch) | |
tree | 9183798a9411a3f45dc6ceb19383f51ba36135d1 /input-keys.c | |
parent | 3aaf5b9b1e4b5249a86db97d67291e22b90e1fef (diff) |
Sync OpenBSD patchset 828:
Support for UTF-8 mouse input (\033[1005h). This was added in xterm 262
and supports larger terminals than the older way.
If the new mouse-utf8 option is on, UTF-8 mouse input is enabled for all
UTF-8 terminals. The option defaults to on if LANG etc are set in the
same manner as the utf8 option.
With help and based on code from hsim at gmx.li.
Diffstat (limited to 'input-keys.c')
-rw-r--r-- | input-keys.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/input-keys.c b/input-keys.c index 34296462..d18c4041 100644 --- a/input-keys.c +++ b/input-keys.c @@ -1,4 +1,4 @@ -/* $Id: input-keys.c,v 1.47 2011-01-03 23:32:04 tcunha Exp $ */ +/* $Id: input-keys.c,v 1.48 2011-01-07 14:34:45 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -201,11 +201,23 @@ input_key(struct window_pane *wp, int key) void input_mouse(struct window_pane *wp, struct mouse_event *m) { - char out[8]; + char buf[10]; + size_t len; if (wp->screen->mode & ALL_MOUSE_MODES) { - xsnprintf(out, sizeof out, - "\033[M%c%c%c", m->b + 32, m->x + 33, m->y + 33); - bufferevent_write(wp->event, out, strlen(out)); + 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(m->x + 33, &buf[len]); + len += utf8_split2(m->y + 33, &buf[len]); + } else { + if (m->b > 223 || m->x >= 222 || m->y > 222) + return; + len = xsnprintf(buf, sizeof buf, "\033[M"); + buf[len++] = m->b + 32; + buf[len++] = m->x + 33; + buf[len++] = m->y + 33; + } + bufferevent_write(wp->event, buf, len); } } |