summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-queue.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-03-08 10:34:20 +0000
committernicm <nicm@openbsd.org>2019-03-08 10:34:20 +0000
commitadfef3cc825948f47024d5fcc73db9b8e5347afd (patch)
treef8b08236873c96512f8f9d9a076b9743eca111ea /usr.bin/tmux/cmd-queue.c
parentDo not use window mode entry after free. (diff)
downloadwireguard-openbsd-adfef3cc825948f47024d5fcc73db9b8e5347afd.tar.xz
wireguard-openbsd-adfef3cc825948f47024d5fcc73db9b8e5347afd.zip
Make the mode used to view command output (a variant of copy mode) use
its own mode definition struct with a different init function rather than calling special setup functions.
Diffstat (limited to 'usr.bin/tmux/cmd-queue.c')
-rw-r--r--usr.bin/tmux/cmd-queue.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c
index 1d49333c60d..633f0f1433b 100644
--- a/usr.bin/tmux/cmd-queue.c
+++ b/usr.bin/tmux/cmd-queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-queue.c,v 1.59 2019/03/07 19:34:22 nicm Exp $ */
+/* $OpenBSD: cmd-queue.c,v 1.60 2019/03/08 10:34:20 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -404,10 +404,10 @@ cmdq_guard(struct cmdq_item *item, const char *guard, int flags)
void
cmdq_print(struct cmdq_item *item, const char *fmt, ...)
{
- struct client *c = item->client;
- struct window *w;
- va_list ap;
- char *tmp, *msg;
+ struct client *c = item->client;
+ struct window_pane *wp;
+ va_list ap;
+ char *tmp, *msg;
va_start(ap, fmt);
@@ -425,9 +425,12 @@ cmdq_print(struct cmdq_item *item, const char *fmt, ...)
evbuffer_add(c->stdout_data, "\n", 1);
server_client_push_stdout(c);
} else {
- w = c->session->curw->window;
- window_copy_init_for_output(w->active);
- window_copy_vadd(w->active, fmt, ap);
+ wp = c->session->curw->window->active;
+ if (wp->mode == NULL || wp->mode->mode != &window_view_mode) {
+ window_pane_reset_mode(wp);
+ window_pane_set_mode(wp, &window_view_mode, NULL, NULL);
+ }
+ window_copy_vadd(wp, fmt, ap);
}
va_end(ap);