mirror of
https://github.com/tmux/tmux.git
synced 2024-12-25 19:08:58 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
6249a4b866
86
cmd-queue.c
86
cmd-queue.c
@ -24,6 +24,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <vis.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@ -823,43 +824,88 @@ cmdq_guard(struct cmdq_item *item, const char *guard, int flags)
|
|||||||
|
|
||||||
/* Show message from command. */
|
/* Show message from command. */
|
||||||
void
|
void
|
||||||
cmdq_print(struct cmdq_item *item, const char *fmt, ...)
|
cmdq_print_data(struct cmdq_item *item, int parse, struct evbuffer *evb)
|
||||||
{
|
{
|
||||||
struct client *c = item->client;
|
struct client *c = item->client;
|
||||||
|
void *data = EVBUFFER_DATA(evb);
|
||||||
|
size_t size = EVBUFFER_LENGTH(evb);
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct window_mode_entry *wme;
|
struct window_mode_entry *wme;
|
||||||
va_list ap;
|
char *sanitized, *msg, *line;
|
||||||
char *tmp, *msg;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
xvasprintf(&msg, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
|
if (!parse) {
|
||||||
|
utf8_stravisx(&msg, data, size, VIS_OCTAL|VIS_CSTYLE|VIS_TAB);
|
||||||
log_debug("%s: %s", __func__, msg);
|
log_debug("%s: %s", __func__, msg);
|
||||||
|
} else {
|
||||||
|
msg = EVBUFFER_DATA(evb);
|
||||||
|
if (msg[size - 1] != '\0')
|
||||||
|
evbuffer_add(evb, "", 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
/* nothing */;
|
goto out;
|
||||||
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
|
||||||
|
if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
if (~c->flags & CLIENT_UTF8) {
|
if (~c->flags & CLIENT_UTF8) {
|
||||||
tmp = msg;
|
sanitized = utf8_sanitize(msg);
|
||||||
msg = utf8_sanitize(tmp);
|
if (c->flags & CLIENT_CONTROL)
|
||||||
free(tmp);
|
control_write(c, "%s", sanitized);
|
||||||
}
|
else
|
||||||
|
file_print(c, "%s\n", sanitized);
|
||||||
|
free(sanitized);
|
||||||
|
} else {
|
||||||
if (c->flags & CLIENT_CONTROL)
|
if (c->flags & CLIENT_CONTROL)
|
||||||
control_write(c, "%s", msg);
|
control_write(c, "%s", msg);
|
||||||
else
|
else
|
||||||
file_print(c, "%s\n", msg);
|
file_print(c, "%s\n", msg);
|
||||||
} else {
|
|
||||||
wp = server_client_get_pane(c);
|
|
||||||
wme = TAILQ_FIRST(&wp->modes);
|
|
||||||
if (wme == NULL || wme->mode != &window_view_mode) {
|
|
||||||
window_pane_set_mode(wp, NULL, &window_view_mode, NULL,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
window_copy_add(wp, 0, "%s", msg);
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wp = server_client_get_pane(c);
|
||||||
|
wme = TAILQ_FIRST(&wp->modes);
|
||||||
|
if (wme == NULL || wme->mode != &window_view_mode)
|
||||||
|
window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL);
|
||||||
|
if (parse) {
|
||||||
|
do {
|
||||||
|
line = evbuffer_readln(evb, NULL, EVBUFFER_EOL_LF);
|
||||||
|
if (line != NULL) {
|
||||||
|
window_copy_add(wp, 1, "%s", line);
|
||||||
|
free(line);
|
||||||
|
}
|
||||||
|
} while (line != NULL);
|
||||||
|
|
||||||
|
size = EVBUFFER_LENGTH(evb);
|
||||||
|
if (size != 0) {
|
||||||
|
line = EVBUFFER_DATA(evb);
|
||||||
|
window_copy_add(wp, 1, "%.*s", (int)size, line);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
window_copy_add(wp, 0, "%s", msg);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (!parse)
|
||||||
free(msg);
|
free(msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show message from command. */
|
||||||
|
void
|
||||||
|
cmdq_print(struct cmdq_item *item, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
struct evbuffer *evb;
|
||||||
|
|
||||||
|
evb = evbuffer_new();
|
||||||
|
if (evb == NULL)
|
||||||
|
fatalx("out of memory");
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
evbuffer_add_vprintf(evb, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
cmdq_print_data(item, 0, evb);
|
||||||
|
evbuffer_free(evb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show error from command. */
|
/* Show error from command. */
|
||||||
|
@ -78,7 +78,8 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
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, *tmp;
|
char *path;
|
||||||
|
struct evbuffer *evb;
|
||||||
|
|
||||||
if (bufname == NULL) {
|
if (bufname == NULL) {
|
||||||
if ((pb = paste_get_top(NULL)) == NULL) {
|
if ((pb = paste_get_top(NULL)) == NULL) {
|
||||||
@ -96,10 +97,12 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
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)) {
|
if (c->session != NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
utf8_stravisx(&tmp, bufdata, bufsize,
|
evb = evbuffer_new();
|
||||||
VIS_OCTAL|VIS_CSTYLE|VIS_TAB);
|
if (evb == NULL)
|
||||||
cmdq_print(item, "%s", tmp);
|
fatalx("out of memory");
|
||||||
free(tmp);
|
evbuffer_add(evb, bufdata, bufsize);
|
||||||
|
cmdq_print_data(item, 1, evb);
|
||||||
|
evbuffer_free(evb);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
path = xstrdup("-");
|
path = xstrdup("-");
|
||||||
|
1
tmux.h
1
tmux.h
@ -2551,6 +2551,7 @@ u_int cmdq_next(struct client *);
|
|||||||
struct cmdq_item *cmdq_running(struct client *);
|
struct cmdq_item *cmdq_running(struct client *);
|
||||||
void cmdq_guard(struct cmdq_item *, const char *, int);
|
void cmdq_guard(struct cmdq_item *, const char *, int);
|
||||||
void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...);
|
void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...);
|
||||||
|
void cmdq_print_data(struct cmdq_item *, int, struct evbuffer *);
|
||||||
void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...);
|
void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...);
|
||||||
|
|
||||||
/* cmd-wait-for.c */
|
/* cmd-wait-for.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user