Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2024-11-15 10:01:11 +00:00
commit d35458e3fe
7 changed files with 34 additions and 43 deletions

View File

@ -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;

View File

@ -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);
@ -947,17 +933,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);
}
}

View File

@ -2358,6 +2358,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)
@ -2377,6 +2378,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)

View File

@ -114,7 +114,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;
@ -155,7 +155,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);
@ -628,7 +628,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);
@ -657,7 +657,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);
/*
@ -672,7 +672,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)

View File

@ -779,11 +779,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;
@ -802,6 +798,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)) ||

4
tmux.h
View File

@ -1303,6 +1303,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,
@ -3221,6 +3224,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 *);

View File

@ -1736,3 +1736,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);
}