From 2c99347e69e9d4204d01c39c2491d19f5ecc8b3f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 7 Mar 2019 19:34:23 +0000 Subject: Tidy changing the mode into window_copy_init_for_output. --- usr.bin/tmux/cfg.c | 3 +-- usr.bin/tmux/cmd-queue.c | 9 ++------- usr.bin/tmux/cmd-run-shell.c | 8 +++----- usr.bin/tmux/window-copy.c | 8 +++++++- 4 files changed, 13 insertions(+), 15 deletions(-) (limited to 'usr.bin/tmux') diff --git a/usr.bin/tmux/cfg.c b/usr.bin/tmux/cfg.c index a6479d884ce..4e7811092ac 100644 --- a/usr.bin/tmux/cfg.c +++ b/usr.bin/tmux/cfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfg.c,v 1.63 2019/02/16 11:42:08 nicm Exp $ */ +/* $OpenBSD: cfg.c,v 1.64 2019/03/07 19:34:22 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -348,7 +348,6 @@ cfg_show_causes(struct session *s) return; wp = s->curw->window->active; - window_pane_set_mode(wp, &window_copy_mode, NULL, NULL); window_copy_init_for_output(wp); for (i = 0; i < cfg_ncauses; i++) { window_copy_add(wp, "%s", cfg_causes[i]); diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c index a5896acab47..1d49333c60d 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.58 2017/08/30 10:33:57 nicm Exp $ */ +/* $OpenBSD: cmd-queue.c,v 1.59 2019/03/07 19:34:22 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott @@ -426,12 +426,7 @@ cmdq_print(struct cmdq_item *item, const char *fmt, ...) server_client_push_stdout(c); } else { w = c->session->curw->window; - if (w->active->mode != &window_copy_mode) { - window_pane_reset_mode(w->active); - window_pane_set_mode(w->active, &window_copy_mode, NULL, - NULL); - window_copy_init_for_output(w->active); - } + window_copy_init_for_output(w->active); window_copy_vadd(w->active, fmt, ap); } diff --git a/usr.bin/tmux/cmd-run-shell.c b/usr.bin/tmux/cmd-run-shell.c index cbb4a888cc9..29ffcb440b8 100644 --- a/usr.bin/tmux/cmd-run-shell.c +++ b/usr.bin/tmux/cmd-run-shell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-run-shell.c,v 1.55 2018/08/27 11:03:34 nicm Exp $ */ +/* $OpenBSD: cmd-run-shell.c,v 1.56 2019/03/07 19:34:22 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha @@ -75,10 +75,8 @@ cmd_run_shell_print(struct job *job, const char *msg) return; } - if (window_pane_set_mode(wp, &window_copy_mode, NULL, NULL) == 0) - window_copy_init_for_output(wp); - if (wp->mode == &window_copy_mode) - window_copy_add(wp, "%s", msg); + window_copy_init_for_output(wp); + window_copy_add(wp, "%s", msg); } static enum cmd_retval diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index a18347b2e23..cef728b83ab 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.206 2019/03/07 19:01:21 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.207 2019/03/07 19:34:22 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -263,6 +263,12 @@ window_copy_init_for_output(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; + if (wp->mode == &window_copy_mode && data->backing != &wp->base) + return; + window_pane_reset_mode(wp); + window_pane_set_mode(wp, &window_copy_mode, NULL, NULL); + + data = wp->modedata; data->backing = xmalloc(sizeof *data->backing); screen_init(data->backing, screen_size_x(&wp->base), screen_size_y(&wp->base), UINT_MAX); -- cgit v1.2.3