From e33c83c6ba77c4a37a6250db0b3a132854d79160 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 13 Oct 2026 22:44:53 +0000 Subject: [PATCH 1/2] Restructure a little bit of code. --- tty-draw.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tty-draw.c b/tty-draw.c index c5d66a169..658c73748 100644 --- a/tty-draw.c +++ b/tty-draw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-draw.c,v 1.18 2026/10/12 15:28:45 nicm Exp $ */ +/* $OpenBSD: tty-draw.c,v 1.19 2026/10/13 22:44:53 nicm Exp $ */ /* * Copyright (c) 2026 Nicholas Marriott @@ -260,15 +260,14 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, } else { /* Get the current cell. */ grid_view_get_cell(gd, px + i, py, &gc); + gcp = &gc; /* Work out empty cells. */ - empty = tty_draw_line_get_empty(&gc, &last, + empty = tty_draw_line_get_empty(gcp, &last, nx - i); - if (empty != 0) - gcp = &gc; - else { + if (empty == 0) { /* Update for codeset if needed. */ - gcp = tty_check_codeset(tty, &gc); + gcp = tty_check_codeset(tty, gcp); /* And for selection. */ if (gcp->flags & GRID_FLAG_SELECTED) { From 61b695097ee45069c74214552d524ba26030ecce Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 13 Oct 2026 23:17:42 +0000 Subject: [PATCH 2/2] Fix some long lines. --- window-copy.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/window-copy.c b/window-copy.c index 3d40ffe24..4949582ec 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.437 2026/10/08 07:50:05 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.438 2026/10/13 23:17:42 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -537,7 +537,8 @@ window_copy_sync_backing(struct window_mode_entry *wme) if (collected > 0) { grid_free_lines(dg, 0, collected); memmove(&dg->linedata[0], &dg->linedata[collected], - (old_hsize + sy - collected) * sizeof *dg->linedata); + (old_hsize + sy - collected) * + sizeof *dg->linedata); memset(&dg->linedata[old_hsize + sy - collected], 0, collected * sizeof *dg->linedata); } @@ -556,7 +557,7 @@ window_copy_sync_backing(struct window_mode_entry *wme) */ dg->hsize = new_hsize; - /* Copy the newly scrolled history, then refresh the viewport. */ + /* Copy the newly scrolled history, then refresh the view. */ if (added > 0) grid_duplicate_lines(dg, kept, sg, kept, added); grid_duplicate_lines(dg, new_hsize, sg, new_hsize, sy); @@ -2314,6 +2315,7 @@ window_copy_cmd_selection_mode(struct window_copy_cmd_state *cs) { struct window_mode_entry *wme = cs->wme; struct options *so = cs->s->options; + struct options *oo = wme->wp->window->options; struct window_copy_mode_data *data = wme->data; struct grid_reader gr; const char *s = args_string(cs->wargs, 0); @@ -2333,7 +2335,8 @@ window_copy_cmd_selection_mode(struct window_copy_cmd_state *cs) /* * Set up the reset positions normally initialized by select-word or - * select-line, including when changing the mode of an existing selection. + * select-line, including when changing the mode of an existing + * selection. */ if (data->cursordrag == CURSORDRAG_SEL) { fx = data->endselx; @@ -2360,8 +2363,7 @@ window_copy_cmd_selection_mode(struct window_copy_cmd_state *cs) grid_reader_start(&gr, data->backing->grid, ex, ey); if (data->selflag == SEL_WORD) { grid_reader_cursor_next_word_end(&gr, data->separators); - if (options_get_number(wme->wp->window->options, "mode-keys") == - MODEKEY_VI) + if (options_get_number(oo, "mode-keys") == MODEKEY_VI) grid_reader_cursor_left(&gr, 1); } else grid_reader_cursor_end_of_line(&gr, 1, 0); @@ -5581,8 +5583,8 @@ window_copy_write_one(struct window_mode_entry *wme, if (gc.flags & GRID_FLAG_PADDING) { if (ctx->s->cy == py && ctx->s->cx <= px + fx) { gc.flags &= ~GRID_FLAG_PADDING; - screen_write_cursormove(ctx, px + fx, py, - 0); + screen_write_cursormove(ctx, px + fx, + py, 0); screen_write_putc(ctx, &gc, ' '); } } else if (gc.flags & GRID_FLAG_TAB) { @@ -5881,7 +5883,7 @@ window_copy_redraw_lines(struct window_mode_entry *wme, u_int py, u_int ny) struct window_copy_mode_data *data = wme->data; struct screen *s = &data->screen; struct screen_write_ctx ctx; - u_int i; + u_int i, off; if (window_copy_line_number_width(wme) != 0) { screen_write_start(&ctx, &data->screen); @@ -5901,9 +5903,8 @@ window_copy_redraw_lines(struct window_mode_entry *wme, u_int py, u_int ny) screen_write_start_pane(&ctx, wp, NULL); for (i = py; i < py + ny; i++) window_copy_write_line(wme, &ctx, i); - screen_write_cursormove(&ctx, - window_copy_cursor_offset(wme, data->cx, screen_size_x(s)), data->cy, - 0); + off = window_copy_cursor_offset(wme, data->cx, screen_size_x(s)); + screen_write_cursormove(&ctx, off, data->cy, 0); screen_write_stop(&ctx); window_pane_scrollbar_redraw(wp);