From 10d689e7354f789f951016f7f4d57a0c2d14e124 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 17 Mar 2022 11:35:37 +0000 Subject: Add an option (scroll-on-clear) to control if tmux scrolls into history on clear, from Robert Lange in GitHub issue 3121. --- options-table.c | 8 ++++++++ screen-write.c | 6 +++++- tmux.1 | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/options-table.c b/options-table.c index 46b96ec4..b0870118 100644 --- a/options-table.c +++ b/options-table.c @@ -1081,6 +1081,14 @@ const struct options_table_entry options_table[] = { "remain-on-exit is enabled." }, + { .name = "scroll-on-clear", + .type = OPTIONS_TABLE_FLAG, + .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, + .default_num = 1, + .text = "Whether the contents of the screen should be scrolled into" + "history when clearing the whole screen." + }, + { .name = "synchronize-panes", .type = OPTIONS_TABLE_FLAG, .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, diff --git a/screen-write.c b/screen-write.c index 0d70f668..aa898f78 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1427,7 +1427,11 @@ screen_write_clearendofscreen(struct screen_write_ctx *ctx, u_int bg) ttyctx.bg = bg; /* Scroll into history if it is enabled and clearing entire screen. */ - if (s->cx == 0 && s->cy == 0 && (gd->flags & GRID_HISTORY)) + if (s->cx == 0 && + s->cy == 0 && + (gd->flags & GRID_HISTORY) && + ctx->wp != NULL && + options_get_number(ctx->wp->options, "scroll-on-clear")) grid_view_clear_history(gd, bg); else { if (s->cx <= sx - 1) diff --git a/tmux.1 b/tmux.1 index 6c9ff820..bc5c1a55 100644 --- a/tmux.1 +++ b/tmux.1 @@ -4476,6 +4476,12 @@ Set the text shown at the bottom of exited panes when .Ic remain-on-exit is enabled. .Pp +.It Xo Ic scroll-on-clear +.Op Ic on | off +.Xc +When the entire screen is cleared and this option is on, scroll the contents of +the screen into history before clearing it. +.Pp .It Xo Ic synchronize-panes .Op Ic on | off .Xc -- cgit v1.2.3