mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Fix show-buffer when run from inside tmux, GitHub issue 2314.
This commit is contained in:
parent
3b089fc69f
commit
743ab5728d
@ -74,11 +74,12 @@ static enum cmd_retval
|
|||||||
cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = cmd_get_args(self);
|
struct args *args = cmd_get_args(self);
|
||||||
|
struct client *c = cmdq_get_client(item);
|
||||||
struct paste_buffer *pb;
|
struct paste_buffer *pb;
|
||||||
int flags;
|
int flags;
|
||||||
const char *bufname = args_get(args, 'b'), *bufdata;
|
const char *bufname = args_get(args, 'b'), *bufdata;
|
||||||
size_t bufsize;
|
size_t bufsize;
|
||||||
char *path;
|
char *path, *tmp;
|
||||||
|
|
||||||
if (bufname == NULL) {
|
if (bufname == NULL) {
|
||||||
if ((pb = paste_get_top(NULL)) == NULL) {
|
if ((pb = paste_get_top(NULL)) == NULL) {
|
||||||
@ -94,9 +95,16 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
bufdata = paste_buffer_data(pb, &bufsize);
|
bufdata = paste_buffer_data(pb, &bufsize);
|
||||||
|
|
||||||
if (cmd_get_entry(self) == &cmd_show_buffer_entry)
|
if (cmd_get_entry(self) == &cmd_show_buffer_entry) {
|
||||||
|
if (c->session != NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
|
utf8_stravisx(&tmp, bufdata, bufsize,
|
||||||
|
VIS_OCTAL|VIS_CSTYLE|VIS_TAB);
|
||||||
|
cmdq_print(item, "%s", tmp);
|
||||||
|
free(tmp);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
|
}
|
||||||
path = xstrdup("-");
|
path = xstrdup("-");
|
||||||
else
|
} else
|
||||||
path = format_single_from_target(item, args->argv[0]);
|
path = format_single_from_target(item, args->argv[0]);
|
||||||
if (args_has(args, 'a'))
|
if (args_has(args, 'a'))
|
||||||
flags = O_APPEND;
|
flags = O_APPEND;
|
||||||
|
@ -514,7 +514,10 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
|||||||
|
|
||||||
if (*ptr == '\001')
|
if (*ptr == '\001')
|
||||||
gc.attr ^= GRID_ATTR_CHARSET;
|
gc.attr ^= GRID_ATTR_CHARSET;
|
||||||
else if (*ptr > 0x1f && *ptr < 0x7f) {
|
else if (*ptr == '\n') {
|
||||||
|
screen_write_linefeed(ctx, 0, 8);
|
||||||
|
screen_write_carriagereturn(ctx);
|
||||||
|
} else if (*ptr > 0x1f && *ptr < 0x7f) {
|
||||||
size++;
|
size++;
|
||||||
screen_write_putc(ctx, &gc, *ptr);
|
screen_write_putc(ctx, &gc, *ptr);
|
||||||
}
|
}
|
||||||
|
1
tmux.h
1
tmux.h
@ -2940,6 +2940,7 @@ enum utf8_state utf8_append(struct utf8_data *, u_char);
|
|||||||
int utf8_isvalid(const char *);
|
int utf8_isvalid(const char *);
|
||||||
int utf8_strvis(char *, const char *, size_t, int);
|
int utf8_strvis(char *, const char *, size_t, int);
|
||||||
int utf8_stravis(char **, const char *, int);
|
int utf8_stravis(char **, const char *, int);
|
||||||
|
int utf8_stravisx(char **, const char *, size_t, int);
|
||||||
char *utf8_sanitize(const char *);
|
char *utf8_sanitize(const char *);
|
||||||
size_t utf8_strlen(const struct utf8_data *);
|
size_t utf8_strlen(const struct utf8_data *);
|
||||||
u_int utf8_strwidth(const struct utf8_data *, ssize_t);
|
u_int utf8_strwidth(const struct utf8_data *, ssize_t);
|
||||||
|
14
utf8.c
14
utf8.c
@ -341,6 +341,20 @@ utf8_stravis(char **dst, const char *src, int flag)
|
|||||||
return (len);
|
return (len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Same as utf8_strvis but allocate the buffer. */
|
||||||
|
int
|
||||||
|
utf8_stravisx(char **dst, const char *src, size_t srclen, int flag)
|
||||||
|
{
|
||||||
|
char *buf;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
buf = xreallocarray(NULL, 4, srclen + 1);
|
||||||
|
len = utf8_strvis(buf, src, srclen, flag);
|
||||||
|
|
||||||
|
*dst = xrealloc(buf, len + 1);
|
||||||
|
return (len);
|
||||||
|
}
|
||||||
|
|
||||||
/* Does this string contain anything that isn't valid UTF-8? */
|
/* Does this string contain anything that isn't valid UTF-8? */
|
||||||
int
|
int
|
||||||
utf8_isvalid(const char *s)
|
utf8_isvalid(const char *s)
|
||||||
|
Loading…
Reference in New Issue
Block a user