summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/input-keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/input-keys.c')
-rw-r--r--usr.bin/tmux/input-keys.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c
index eea2104e1f4..0c16317f51f 100644
--- a/usr.bin/tmux/input-keys.c
+++ b/usr.bin/tmux/input-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input-keys.c,v 1.20 2011/01/01 03:43:20 nicm Exp $ */
+/* $OpenBSD: input-keys.c,v 1.21 2011/01/03 23:35:21 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -202,11 +202,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);
}
}