summaryrefslogtreecommitdiffstats
path: root/utf8.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-01-03 23:35:21 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-01-03 23:35:21 +0000
commitac3b78a84178a308536a56ea114b0f6f8ce6fb47 (patch)
tree71c4a4c1030c29d670c965315b0c87dccf9c8972 /utf8.c
parent5158dd9a8dddf34a00ec6359840488d34faabd88 (diff)
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 'utf8.c')
-rw-r--r--utf8.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/utf8.c b/utf8.c
index 00b1c736..b276d872 100644
--- a/utf8.c
+++ b/utf8.c
@@ -318,6 +318,19 @@ utf8_combine(const struct utf8_data *utf8data)
return (value);
}
+/* Split a two-byte UTF-8 character. */
+u_int
+utf8_split2(u_int uc, u_char *ptr)
+{
+ if (uc > 0x7f) {
+ ptr[0] = (uc >> 6) | 0xc0;
+ ptr[1] = (uc & 0x3f) | 0x80;
+ return (2);
+ }
+ ptr[0] = uc;
+ return (1);
+}
+
/* Lookup width of UTF-8 data in tree. */
u_int
utf8_width(const struct utf8_data *utf8data)