From c294c2bf54a3ec56271a78c284f84e75a8119731 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 05:34:56 +0200 Subject: Merging upstream version 3.4. Signed-off-by: Daniel Baumann --- cmd-queue.c | 51 +++++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) (limited to 'cmd-queue.c') diff --git a/cmd-queue.c b/cmd-queue.c index 8325e2e..e188afc 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -236,8 +236,10 @@ cmdq_link_state(struct cmdq_state *state) /* Make a copy of a state. */ struct cmdq_state * -cmdq_copy_state(struct cmdq_state *state) +cmdq_copy_state(struct cmdq_state *state, struct cmd_find_state *current) { + if (current != NULL) + return (cmdq_new_state(current, &state->event, state->flags)); return (cmdq_new_state(&state->current, &state->event, state->flags)); } @@ -821,45 +823,30 @@ cmdq_guard(struct cmdq_item *item, const char *guard, int flags) control_write(c, "%%%s %ld %u %d", guard, t, number, flags); } +/* Show message from command. */ +void +cmdq_print_data(struct cmdq_item *item, int parse, struct evbuffer *evb) +{ + server_client_print(item->client, parse, evb); +} + /* Show message from command. */ void cmdq_print(struct cmdq_item *item, const char *fmt, ...) { - struct client *c = item->client; - struct window_pane *wp; - struct window_mode_entry *wme; - va_list ap; - char *tmp, *msg; + va_list ap; + struct evbuffer *evb; + + evb = evbuffer_new(); + if (evb == NULL) + fatalx("out of memory"); va_start(ap, fmt); - xvasprintf(&msg, fmt, ap); + evbuffer_add_vprintf(evb, fmt, ap); va_end(ap); - log_debug("%s: %s", __func__, msg); - - if (c == NULL) - /* nothing */; - else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) { - if (~c->flags & CLIENT_UTF8) { - tmp = msg; - msg = utf8_sanitize(tmp); - free(tmp); - } - if (c->flags & CLIENT_CONTROL) - control_write(c, "%s", msg); - else - 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); - } - - free(msg); + cmdq_print_data(item, 0, evb); + evbuffer_free(evb); } /* Show error from command. */ -- cgit v1.2.3