diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2014-04-15 00:33:56 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2014-04-15 00:33:56 +0100 |
commit | 4abc8f717a5a786a4dd9e4f24d64ec76b0829993 (patch) | |
tree | d52bbbd572c1fb638ac60e75a43d92ede1955155 /paste.c | |
parent | 8e1cef404022422f9f57c72d139f19a82a70a791 (diff) | |
parent | 57c514d2f85f9d1c81601bae32131f1cd2948422 (diff) | |
download | rtmux-4abc8f717a5a786a4dd9e4f24d64ec76b0829993.tar.gz rtmux-4abc8f717a5a786a4dd9e4f24d64ec76b0829993.tar.bz2 rtmux-4abc8f717a5a786a4dd9e4f24d64ec76b0829993.zip |
Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code
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); } |