summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/tmux/layout.c9
-rw-r--r--usr.bin/tmux/screen-redraw.c35
-rw-r--r--usr.bin/tmux/screen-write.c4
-rw-r--r--usr.bin/tmux/screen.c12
-rw-r--r--usr.bin/tmux/server-client.c10
-rw-r--r--usr.bin/tmux/tmux.h6
-rw-r--r--usr.bin/tmux/window.c15
7 files changed, 41 insertions, 50 deletions
diff --git a/usr.bin/tmux/layout.c b/usr.bin/tmux/layout.c
index b89e9574f00..b7678048d56 100644
--- a/usr.bin/tmux/layout.c
+++ b/usr.bin/tmux/layout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: layout.c,v 1.49 2024/11/05 09:41:17 nicm Exp $ */
+/* $OpenBSD: layout.c,v 1.50 2024/11/15 09:01:16 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -292,7 +292,7 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
struct window_pane *wp;
struct layout_cell *lc;
int status, scrollbars, sb_pos;
- u_int sx, sy, mode;
+ u_int sx, sy;
status = options_get_number(w->options, "pane-border-status");
scrollbars = options_get_number(w->options, "pane-scrollbars");
@@ -313,10 +313,7 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
sy--;
}
- mode = window_pane_mode(wp);
- if (scrollbars == PANE_SCROLLBARS_ALWAYS ||
- (scrollbars == PANE_SCROLLBARS_MODAL &&
- mode != WINDOW_PANE_NO_MODE)) {
+ if (window_pane_show_scrollbar(wp, scrollbars)) {
if (sb_pos == PANE_SCROLLBARS_LEFT) {
sx = sx - PANE_SCROLLBARS_WIDTH;
wp->xoff = wp->xoff + PANE_SCROLLBARS_WIDTH;
diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c
index 0326775baf1..1423c9fcefb 100644
--- a/usr.bin/tmux/screen-redraw.c
+++ b/usr.bin/tmux/screen-redraw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-redraw.c,v 1.101 2024/11/12 09:32:56 nicm Exp $ */
+/* $OpenBSD: screen-redraw.c,v 1.102 2024/11/15 09:01:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -137,9 +137,7 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
}
/* Are scrollbars enabled? */
- if (pane_scrollbars == PANE_SCROLLBARS_ALWAYS ||
- (pane_scrollbars == PANE_SCROLLBARS_MODAL &&
- window_pane_mode(wp) != WINDOW_PANE_NO_MODE))
+ if (window_pane_show_scrollbar(wp, pane_scrollbars))
sb_w = PANE_SCROLLBARS_WIDTH;
/*
@@ -364,9 +362,7 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, u_int px, u_int py,
*wpp = wp;
/* Check if CELL_SCROLLBAR */
- if (pane_scrollbars == PANE_SCROLLBARS_ALWAYS ||
- (pane_scrollbars == PANE_SCROLLBARS_MODAL &&
- window_pane_mode(wp) != WINDOW_PANE_NO_MODE)) {
+ if (window_pane_show_scrollbar(wp, pane_scrollbars)) {
if (pane_status == PANE_STATUS_TOP)
line = wp->yoff - 1;
@@ -669,11 +665,9 @@ screen_redraw_pane(struct client *c, struct window_pane *wp,
int redraw_scrollbar_only)
{
struct screen_redraw_ctx ctx;
- int pane_scrollbars, mode;
if (!window_pane_visible(wp))
return;
- mode = window_pane_mode(wp);
screen_redraw_set_context(c, &ctx);
tty_sync_start(&c->tty);
@@ -682,15 +676,7 @@ screen_redraw_pane(struct client *c, struct window_pane *wp,
if (!redraw_scrollbar_only)
screen_redraw_draw_pane(&ctx, wp);
- /*
- * Redraw scrollbar if needed. Always redraw scrollbar in a mode because
- * if redrawing a pane, it's because pane has scrolled.
- */
- pane_scrollbars = ctx.pane_scrollbars;
- if (pane_scrollbars == PANE_SCROLLBARS_MODAL &&
- mode == WINDOW_PANE_NO_MODE)
- pane_scrollbars = PANE_SCROLLBARS_OFF;
- if (pane_scrollbars != PANE_SCROLLBARS_OFF)
+ if (window_pane_show_scrollbar(wp, ctx.pane_scrollbars))
screen_redraw_draw_pane_scrollbar(&ctx, wp);
tty_reset(&c->tty);
@@ -943,17 +929,8 @@ screen_redraw_draw_pane_scrollbars(struct screen_redraw_ctx *ctx)
log_debug("%s: %s @%u", __func__, c->name, w->id);
TAILQ_FOREACH(wp, &w->panes, entry) {
- switch (ctx->pane_scrollbars) {
- case PANE_SCROLLBARS_OFF:
- return;
- case PANE_SCROLLBARS_MODAL:
- if (window_pane_mode(wp) == WINDOW_PANE_NO_MODE)
- return;
- break;
- case PANE_SCROLLBARS_ALWAYS:
- break;
- }
- if (window_pane_visible(wp))
+ if (window_pane_show_scrollbar(wp, ctx->pane_scrollbars) &&
+ window_pane_visible(wp))
screen_redraw_draw_pane_scrollbar(ctx, wp);
}
}
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index 38d118ed9f3..dce13a6c626 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.230 2024/11/08 08:51:36 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.231 2024/11/15 09:01:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2204,6 +2204,7 @@ screen_write_alternateon(struct screen_write_ctx *ctx, struct grid_cell *gc,
screen_write_collect_flush(ctx, 0, __func__);
screen_alternate_on(ctx->s, gc, cursor);
+ layout_fix_panes(wp->window, NULL);
screen_write_initctx(ctx, &ttyctx, 1);
if (ttyctx.redraw_cb != NULL)
@@ -2223,6 +2224,7 @@ screen_write_alternateoff(struct screen_write_ctx *ctx, struct grid_cell *gc,
screen_write_collect_flush(ctx, 0, __func__);
screen_alternate_off(ctx->s, gc, cursor);
+ layout_fix_panes(wp->window, NULL);
screen_write_initctx(ctx, &ttyctx, 1);
if (ttyctx.redraw_cb != NULL)
diff --git a/usr.bin/tmux/screen.c b/usr.bin/tmux/screen.c
index e70edd5fdb9..b100f138fc1 100644
--- a/usr.bin/tmux/screen.c
+++ b/usr.bin/tmux/screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen.c,v 1.87 2024/10/01 08:01:19 nicm Exp $ */
+/* $OpenBSD: screen.c,v 1.88 2024/11/15 09:01:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -111,7 +111,7 @@ screen_reinit(struct screen *s)
if (options_get_number(global_options, "extended-keys") == 2)
s->mode = (s->mode & ~EXTENDED_KEY_MODES)|MODE_KEYS_EXTENDED;
- if (s->saved_grid != NULL)
+ if (SCREEN_IS_ALTERNATE(s))
screen_alternate_off(s, NULL, 0);
s->saved_cx = UINT_MAX;
s->saved_cy = UINT_MAX;
@@ -147,7 +147,7 @@ screen_free(struct screen *s)
if (s->write_list != NULL)
screen_write_free_list(s);
- if (s->saved_grid != NULL)
+ if (SCREEN_IS_ALTERNATE(s))
grid_destroy(s->saved_grid);
grid_destroy(s->grid);
@@ -612,7 +612,7 @@ screen_alternate_on(struct screen *s, struct grid_cell *gc, int cursor)
{
u_int sx, sy;
- if (s->saved_grid != NULL)
+ if (SCREEN_IS_ALTERNATE(s))
return;
sx = screen_size_x(s);
sy = screen_size_y(s);
@@ -641,7 +641,7 @@ screen_alternate_off(struct screen *s, struct grid_cell *gc, int cursor)
* If the current size is different, temporarily resize to the old size
* before copying back.
*/
- if (s->saved_grid != NULL)
+ if (SCREEN_IS_ALTERNATE(s))
screen_resize(s, s->saved_grid->sx, s->saved_grid->sy, 0);
/*
@@ -656,7 +656,7 @@ screen_alternate_off(struct screen *s, struct grid_cell *gc, int cursor)
}
/* If not in the alternate screen, do nothing more. */
- if (s->saved_grid == NULL) {
+ if (!SCREEN_IS_ALTERNATE(s)) {
if (s->cx > screen_size_x(s) - 1)
s->cx = screen_size_x(s) - 1;
if (s->cy > screen_size_y(s) - 1)
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 9af2a290382..c7c84377027 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.416 2024/11/12 09:32:56 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.417 2024/11/15 09:01:16 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -783,11 +783,7 @@ have_event:
/* Try the scrollbar next to a pane. */
sb = options_get_number(wo, "pane-scrollbars");
- sb_pos = options_get_number(wo,
- "pane-scrollbars-position");
- if (sb == PANE_SCROLLBARS_ALWAYS ||
- (sb == PANE_SCROLLBARS_MODAL &&
- window_pane_mode(wp) != WINDOW_PANE_NO_MODE))
+ if (window_pane_show_scrollbar(wp, sb))
sb_w = PANE_SCROLLBARS_WIDTH;
else
sb_w = 0;
@@ -806,6 +802,8 @@ have_event:
if ((pane_status != PANE_STATUS_OFF && py != line) ||
(wp->yoff == 0 && py < wp->sy) ||
(py >= wp->yoff && py < wp->yoff + wp->sy)) {
+ sb_pos = options_get_number(wo,
+ "pane-scrollbars-position");
if ((sb_pos == PANE_SCROLLBARS_RIGHT &&
(px >= wp->xoff + wp->sx &&
px < wp->xoff + wp->sx + sb_w)) ||
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index f098f452293..60ce1c890be 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1240 2024/11/12 09:32:56 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1241 2024/11/15 09:01:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1272,6 +1272,9 @@ TAILQ_HEAD(winlink_stack, winlink);
#define PANE_SCROLLBARS_WIDTH 1
#define PANE_SCROLLBARS_PADDING 0
+/* True if screen in alternate screen. */
+#define SCREEN_IS_ALTERNATE(s) ((s)->saved_grid != NULL)
+
/* Layout direction. */
enum layout_type {
LAYOUT_LEFTRIGHT,
@@ -3173,6 +3176,7 @@ void window_pane_update_used_data(struct window_pane *,
void window_set_fill_character(struct window *);
void window_pane_default_cursor(struct window_pane *);
int window_pane_mode(struct window_pane *);
+int window_pane_show_scrollbar(struct window_pane *, int);
/* layout.c */
u_int layout_count_cells(struct layout_cell *);
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index e916410608c..f30a30ffd91 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.296 2024/11/05 09:41:17 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.297 2024/11/15 09:01:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1726,3 +1726,16 @@ window_pane_mode(struct window_pane *wp)
}
return (WINDOW_PANE_NO_MODE);
}
+
+/* Return 1 if scrollbar is or should be displayed. */
+int
+window_pane_show_scrollbar(struct window_pane *wp, int sb_option)
+{
+ if (SCREEN_IS_ALTERNATE(wp->screen))
+ return (0);
+ if (sb_option == PANE_SCROLLBARS_ALWAYS ||
+ (sb_option == PANE_SCROLLBARS_MODAL &&
+ window_pane_mode(wp) != WINDOW_PANE_NO_MODE))
+ return (1);
+ return (0);
+}