From 6f8960651ffac4b9858da2af09b16792923f0f4c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 00:20:56 -0300 Subject: body_layer: paintPointerSelection finds its pane's tag and body tops and its rows' insets itself (the tag's text inset, the body's gutter), where its six callers each passed in the same four values Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/body_layer.zig | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/body_layer.zig') diff --git a/src/body_layer.zig b/src/body_layer.zig index b514cabe..2fc1454c 100644 --- a/src/body_layer.zig +++ b/src/body_layer.zig @@ -111,15 +111,12 @@ fn paintSourceSelection(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, rows: []c } } +/// A pointer sweep over pane `pane`'s rows in `r`, its tag's and its body's. pub fn paintPointerSelection( p: *Pardes, s: *Surface, pane: *Pane, r: Rect, - tx: u16, - tw: u16, - tag_y: u16, - body_y: u16, sl: Pane.Sel, /// Rows of the selection above this are left alone. from_row: u16, @@ -127,6 +124,8 @@ pub fn paintPointerSelection( fg: ?[3]u8, ) void { if (pane.pointerSelection(sl)) |rows| return paintSourceSelection(p, s, pane, r, rows, bg, fg); + const tag_y = p.tagTop(pane, r); + const body_y = p.bodyTop(pane, r); var row: u16 = 0; while (row < r.h) : (row += 1) { if (row < from_row) continue; @@ -138,8 +137,9 @@ pub fn paintPointerSelection( // row zero in Sel space and starts at its real first text cell. const scroll: i32 = if (row < pane.tag_rows) pane.tag_scroll else 0; const col: i32 = if (pane.file != null and row >= pane.tag_rows) @max(c0, @as(i32, panes.File.gutterWidth(pane))) else @max(0, c0 - scroll); - const row_x = if (row < pane.tag_rows) r.x + @min(TAG_TEXT_INSET, r.w) else tx; - const row_width = if (row < pane.tag_rows) r.w -| TAG_TEXT_INSET else tw; + const inset = if (row < pane.tag_rows) TAG_TEXT_INSET else config.GUTTER; + const row_x = r.x + @min(inset, r.w); + const row_width = r.w -| inset; const end = @min(c1 - scroll + 1, row_width); if (col < end) s.tint(row_x + @as(u16, @intCast(col)), sy, @intCast(end - col), bg, fg); } @@ -234,7 +234,6 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane const chrome = p.chromeTheme(); const tx = r.x + config.GUTTER; const tw = r.w - config.GUTTER; - const tag_y = p.tagTop(pane, r); // Below the notice bands: they are stacked at the top of the body the // way tree-sitter context rows are, so the body starts under them // rather than being painted over by them. @@ -258,7 +257,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane // the rows, which paint over it. const sweep = pane.sel[pardes.sel_slot]; if (sweep.state != .none and (sweep.state != .done or pardes.sel_slot == 0) and @min(sweep.r0, sweep.r1) < pane.tag_rows) - paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, sweep, pane.tag_rows, th.sel_bg, th.sel_fg); + paintPointerSelection(p, s, pane, r, sweep, pane.tag_rows, th.sel_bg, th.sel_fg); { // The rows themselves. `bodyText` above is only the string BUILD; // this is what writes it into the surface. @@ -303,7 +302,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane if (preview.file_word) |word| panes.File.paintWordSelection(p, s, pane, r, word.row, word.lo, word.hi, preview_bg) else if (preview.sel) |sel| - paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, sel, pane.tag_rows, preview_bg, null); + paintPointerSelection(p, s, pane, r, sel, pane.tag_rows, preview_bg, null); } } const modal_hover = if (p.look_hover_preview) |preview| @@ -316,7 +315,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane // A select sweep over the tag is the tag's selection, painted there // in the tag's own selection colours. if (b == pardes.sel_slot and @min(sl.r0, sl.r1) < pane.tag_rows) continue; - paintPointerSelection(p, s, pane, r, tx, tw, tag_y, body_y, sl, pane.tag_rows, sel_btn[b], buttonInks(th)[b]); + paintPointerSelection(p, s, pane, r, sl, pane.tag_rows, sel_btn[b], buttonInks(th)[b]); } const preview = normal.selRegexArmed(pane) != null; const show_prim = (pane.body.mode == .normal and pane.body.vsel.active) or preview or -- cgit v1.3