Some code tidying up.

This commit is contained in:
nicm
2026-05-23 07:22:50 +00:00
parent 143a177055
commit 5c3a4746b7
3 changed files with 39 additions and 48 deletions

View File

@@ -288,7 +288,7 @@ layout_parse(struct window *w, const char *layout, char **cause)
if (floating_lc != NULL) if (floating_lc != NULL)
layout_assign(&wp, floating_lc, PANE_FLOATING); layout_assign(&wp, floating_lc, PANE_FLOATING);
/* Fix pane Z indexes. */ /* Fix pane z-indexes. */
while (!TAILQ_EMPTY(&w->z_index)) { while (!TAILQ_EMPTY(&w->z_index)) {
wp = TAILQ_FIRST(&w->z_index); wp = TAILQ_FIRST(&w->z_index);
TAILQ_REMOVE(&w->z_index, wp, zentry); TAILQ_REMOVE(&w->z_index, wp, zentry);

View File

@@ -233,7 +233,7 @@ layout_make_node(struct layout_cell *lc, enum layout_type type)
lc->wp = NULL; lc->wp = NULL;
} }
/* Fix Z indexes. */ /* Fix z-indexes. */
void void
layout_fix_zindexes(struct window *w, struct layout_cell *lc) layout_fix_zindexes(struct window *w, struct layout_cell *lc)
{ {

View File

@@ -711,10 +711,8 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx)
} }
r = screen_redraw_get_visible_ranges(wp, x, yoff, width, NULL); r = screen_redraw_get_visible_ranges(wp, x, yoff, width, NULL);
if (ctx->statustop) if (ctx->statustop)
yoff += ctx->statuslines; yoff += ctx->statuslines;
for (i = 0; i < r->used; i++) { for (i = 0; i < r->used; i++) {
ri = &r->ranges[i]; ri = &r->ranges[i];
if (ri->nx == 0) if (ri->nx == 0)
@@ -1265,7 +1263,6 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px,
return (r); return (r);
} }
/* Draw one pane. */ /* Draw one pane. */
static void static void
screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp)
@@ -1289,25 +1286,20 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp)
wp->xoff >= (int)ctx->ox + (int)ctx->sx) wp->xoff >= (int)ctx->ox + (int)ctx->sx)
return; return;
/* woy is window y offset in tty. */
if (ctx->statustop) if (ctx->statustop)
woy = ctx->statuslines; woy = ctx->statuslines;
else else
woy = 0; woy = 0;
for (j = 0; j < wp->sy; j++) { for (j = 0; j < wp->sy; j++) {
if (wp->yoff + (int)j < (int)ctx->oy || if (wp->yoff + (int)j < (int)ctx->oy ||
wp->yoff + (int)j >= (int)ctx->oy + (int)ctx->sy) wp->yoff + (int)j >= (int)ctx->oy + (int)ctx->sy)
continue; continue;
wy = wp->yoff + j; /* y line within window w. */ wy = wp->yoff + j; /* y line within window w */
py = woy + wy - ctx->oy; /* y line within tty. */ py = woy + wy - ctx->oy; /* y line within tty */
if (py > tty->sy) if (py > tty->sy) {
/* Continue if this line is off of tty. */ /* Continue if this line is off of tty. */
continue; continue;
}
/* Note: i is apparenty not used now that the vr array
* returns where in s to read from.
*/
if (wp->xoff >= (int)ctx->ox && if (wp->xoff >= (int)ctx->ox &&
wp->xoff + (int)wp->sx <= (int)ctx->ox + (int)ctx->sx) { wp->xoff + (int)wp->sx <= (int)ctx->ox + (int)ctx->sx) {
/* All visible. */ /* All visible. */
@@ -1336,22 +1328,15 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp)
/* Get visible ranges of line before we draw it. */ /* Get visible ranges of line before we draw it. */
r = screen_redraw_get_visible_ranges(wp, wx, wy, width, NULL); r = screen_redraw_get_visible_ranges(wp, wx, wy, width, NULL);
tty_default_colours(&defaults, wp); tty_default_colours(&defaults, wp);
for (i = 0; i < r->used; i++) { for (i = 0; i < r->used; i++) {
ri = &r->ranges[i]; ri = &r->ranges[i];
if (ri->nx == 0) if (ri->nx == 0)
continue; continue;
px = ri->px; tty_draw_line(tty, s, ri->px - wp->xoff, j, ri->nx,
tty_draw_line(tty, s, ri->px - wp->xoff, j, ri->px, py, &defaults, palette);
ri->nx, px, py, &defaults, palette);
} }
} }
#ifdef ENABLE_SIXEL
tty_draw_images(c, wp, s);
#endif
} }
/* Draw the panes scrollbars */ /* Draw the panes scrollbars */
@@ -1440,8 +1425,8 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
struct visible_ranges *r; struct visible_ranges *r;
/* /*
* Size and offset of window relative to tty. * Size and offset of window relative to tty. Status at top offsets
* Status at top offsets window downward. * window downward.
*/ */
sx = ctx->sx; sx = ctx->sx;
sy = tty->sy - ctx->statuslines; sy = tty->sy - ctx->statuslines;
@@ -1449,8 +1434,8 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
oy = ctx->oy; oy = ctx->oy;
if (ctx->statustop) { if (ctx->statustop) {
sb_y += ctx->statuslines; sb_y += ctx->statuslines;
sy += ctx->statuslines; /* Height of window in tty. */ sy += ctx->statuslines; /* height of window */
oy += ctx->statuslines; /* Top of window in tty. */ oy += ctx->statuslines; /* top of window */
} }
gc = sb_style->gc; gc = sb_style->gc;
@@ -1458,17 +1443,20 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
slgc.fg = gc.bg; slgc.fg = gc.bg;
slgc.bg = gc.fg; slgc.bg = gc.fg;
if (sb_x + (int)sb_w < 0 || sb_x >= sx || sb_y >= sy) if (sb_x + (int)sb_w < 0 || sb_x >= sx || sb_y >= sy) {
/* Whole sb off screen. */ /* Whole scrollbar is off screen. */
return; return;
if (sb_x < 0) }
/* Part of sb on screen. */ if (sb_x < 0) {
/* Part of scrollbar on screen. */
imin = - sb_x; imin = - sb_x;
}
imax = sb_w + sb_pad; imax = sb_w + sb_pad;
if ((int)imax + sb_x > sx) { if ((int)imax + sb_x > sx) {
if (sb_x > sx) if (sb_x > sx) {
/* Whole sb off screen. */ /* Whole scrollbar off screen. */
return; return;
}
imax = sx - sb_x; imax = sx - sb_x;
} }
jmax = sb_h; jmax = sb_h;
@@ -1483,29 +1471,32 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
* subtracting the pan offset oy. * subtracting the pan offset oy.
*/ */
sb_tty_y = sb_y - oy; /* scrollbar top in tty coordinates */ sb_tty_y = sb_y - oy; /* scrollbar top in tty coordinates */
if (sb_tty_y > (int)sy) {
if (sb_tty_y > (int)sy) /* Whole scrollbar is off screen. */
/* Whole sb off screen. */
return; return;
if (sb_tty_y < 0) }
if (sb_tty_y < 0) {
/* Scrollbar starts above visible area; skip those rows. */ /* Scrollbar starts above visible area; skip those rows. */
jmin = -sb_tty_y; jmin = -sb_tty_y;
if (sb_tty_y + (int)sb_h <= 0) }
/* Whole sb above visible area. */ if (sb_tty_y + (int)sb_h <= 0) {
/* Whole scrollbar above visible area. */
return; return;
}
jmax = sb_h; jmax = sb_h;
if (sb_tty_y + (int)jmax > (int)sy) if (sb_tty_y + (int)jmax > (int)sy) {
/* Clip to height of tty. */ /* Clip to height of tty. */
jmax = sy - sb_tty_y; jmax = sy - sb_tty_y;
}
for (j = jmin; j < jmax; j++) { for (j = jmin; j < jmax; j++) {
wy = sb_y + j; /* window y coordinate. */ wy = sb_y + j; /* window y coordinate */
py = sb_tty_y + j; /* tty y coordinate. */ py = sb_tty_y + j;/* tty y coordinate */
r = tty_check_overlay_range(tty, sb_x, wy, imax); r = tty_check_overlay_range(tty, sb_x, wy, imax);
r = screen_redraw_get_visible_ranges(wp, sb_x, wy, imax, r); r = screen_redraw_get_visible_ranges(wp, sb_x, wy, imax, r);
for (i = imin; i < imax; i++) { for (i = imin; i < imax; i++) {
px = sb_x + ox + i; /* tty x coordinate. */ px = sb_x + ox + i; /* tty x coordinate */
wx = sb_x + i; /* window x coordinate. */ wx = sb_x + i; /* window x coordinate */
if (wx < xoff - (int)sb_w - (int)sb_pad || if (wx < xoff - (int)sb_w - (int)sb_pad ||
px >= sx || px < 0 || px >= sx || px < 0 ||
wy < yoff - 1 || wy < yoff - 1 ||