summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/window-buffer.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-12-13 09:15:13 +0000
committernicm <nicm@openbsd.org>2019-12-13 09:15:13 +0000
commit8917ecad1db27f399cabbae1a6731b1d90b13fcb (patch)
tree583dadcc98e00910c58f58df09c065543796e699 /usr.bin/tmux/window-buffer.c
parentRemove show_rib_summary_head() it is no longer used. (diff)
downloadwireguard-openbsd-8917ecad1db27f399cabbae1a6731b1d90b13fcb.tar.xz
wireguard-openbsd-8917ecad1db27f399cabbae1a6731b1d90b13fcb.zip
Show UTF-8 in choose-buffer mode. From KOIE Hidetaka.
Diffstat (limited to 'usr.bin/tmux/window-buffer.c')
-rw-r--r--usr.bin/tmux/window-buffer.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/usr.bin/tmux/window-buffer.c b/usr.bin/tmux/window-buffer.c
index 9a9d836eee5..f5a599cda07 100644
--- a/usr.bin/tmux/window-buffer.c
+++ b/usr.bin/tmux/window-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-buffer.c,v 1.23 2019/12/03 10:47:23 nicm Exp $ */
+/* $OpenBSD: window-buffer.c,v 1.24 2019/12/13 09:15:13 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -208,9 +208,9 @@ window_buffer_draw(__unused void *modedata, void *itemdata,
{
struct window_buffer_itemdata *item = itemdata;
struct paste_buffer *pb;
- char line[1024];
- const char *pdata, *end, *cp;
- size_t psize, at;
+ const char *pdata, *start, *end;
+ char *buf = NULL;
+ size_t psize, len;
u_int i, cx = ctx->s->cx, cy = ctx->s->cy;
pb = paste_get_name(item->name);
@@ -219,27 +219,22 @@ window_buffer_draw(__unused void *modedata, void *itemdata,
pdata = end = paste_buffer_data(pb, &psize);
for (i = 0; i < sy; i++) {
- at = 0;
- while (end != pdata + psize && *end != '\n') {
- if ((sizeof line) - at > 5) {
- cp = vis(line + at, *end, VIS_OCTAL|VIS_TAB, 0);
- at = cp - line;
- }
+ start = end;
+ while (end != pdata + psize && *end != '\n')
end++;
- }
- if (at > sx)
- at = sx;
- line[at] = '\0';
-
- if (*line != '\0') {
+ buf = xreallocarray(buf, 4, end - start + 1);
+ len = utf8_strvis(buf, start, end - start, VIS_OCTAL|VIS_TAB);
+ if (*buf != '\0') {
screen_write_cursormove(ctx, cx, cy + i, 0);
- screen_write_puts(ctx, &grid_default_cell, "%s", line);
+ screen_write_nputs(ctx, sx, &grid_default_cell, "%s",
+ buf);
}
if (end == pdata + psize)
break;
end++;
}
+ free(buf);
}
static int