diff options
author | Thomas Adam <thomas@xteddy.org> | 2014-04-05 12:36:14 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2014-04-05 12:36:14 +0100 |
commit | 0c99c7dbff21082a5f0774e6193b9c9b9a160882 (patch) | |
tree | 852fa9fde3126091fa90ee6604097373076772b1 /paste.c | |
parent | 806d5dcb17c26d2abcbf4328a9ec419ada3d4a3f (diff) | |
parent | acef311fe356f408690e9f94727ed63a934b742f (diff) | |
download | rtmux-0c99c7dbff21082a5f0774e6193b9c9b9a160882.tar.gz rtmux-0c99c7dbff21082a5f0774e6193b9c9b9a160882.tar.bz2 rtmux-0c99c7dbff21082a5f0774e6193b9c9b9a160882.zip |
Merge branch 'obsd-master'
Conflicts:
Makefile
tty-keys.c
Diffstat (limited to 'paste.c')
-rw-r--r-- | paste.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -147,25 +147,26 @@ paste_replace(struct paste_stack *ps, u_int idx, char *data, size_t size) return (0); } -/* Convert a buffer into a visible string. */ +/* Convert start of buffer into a nice string. */ char * -paste_print(struct paste_buffer *pb, size_t width) +paste_make_sample(struct paste_buffer *pb, int utf8flag) { - char *buf; - size_t len, used; - - if (width < 3) - width = 3; - buf = xmalloc(width * 4 + 1); + char *buf; + size_t len, used; + const int flags = VIS_OCTAL|VIS_TAB|VIS_NL; + const size_t width = 200; len = pb->size; if (len > width) len = width; + buf = xmalloc(len * 4 + 4); - used = strvisx(buf, pb->data, len, VIS_OCTAL|VIS_TAB|VIS_NL); + if (utf8flag) + used = utf8_strvis(buf, pb->data, len, flags); + else + used = strvisx(buf, pb->data, len, flags); if (pb->size > width || used > width) - strlcpy(buf + width - 3, "...", 4); - + strlcpy(buf + width, "...", 4); return (buf); } |