diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:33:23 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:02:08 -0300 |
| commit | 07447259192dba875cdeb5767927f7512c2595b4 (patch) | |
| tree | 55177a00e6402759e6b683b1acf025c63cc23eaa /src/Messages.zig | |
| parent | 8660de901a08b98cc4668ac433974879a6bff0db (diff) | |
| download | pardes-07447259192dba875cdeb5767927f7512c2595b4.tar.gz pardes-07447259192dba875cdeb5767927f7512c2595b4.zip | |
Messages: a notice chip's width is worked out where collectNotices places the chip, where noticeCols, called only there, took a Pardes it never read
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Messages.zig')
| -rw-r--r-- | src/Messages.zig | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/Messages.zig b/src/Messages.zig index 371ed168..891caf77 100644 --- a/src/Messages.zig +++ b/src/Messages.zig @@ -61,19 +61,6 @@ fn leaderText(p: *const Pardes, buf: *[16]u8) []const u8 { return buf[0..end]; } -/// How wide a notice chip is, in grid columns: its own text plus a blank -/// cell either side. A notice is an OVERLAY over the body's top rows, not -/// a row taken from them, so it is sized to its message and never to the -/// pane. Counted in GRID columns rather than scaled into the tagline face -/// it is drawn in, because the canonical grid is what a terminal client -/// draws and a chip narrower than its own text there would clip it; the -/// tagline face simply leaves a little more room inside the chip. -pub fn noticeCols(p: *const Pardes, text: []const u8, limit: u16) u16 { - _ = p; - if (limit == 0) return 0; - return @intCast(std.math.clamp(panes.File.displayWidth(text) + 2, 1, @as(usize, limit))); -} - const Printed = struct { left: u16, dropped: usize }; /// Prints `text` flush with the right edge of the band, and answers the @@ -593,14 +580,18 @@ test "an error reads as words and a failure is cut between them" { /// them instead of letting the last one win the row. pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { collectBands(p, pane, r, id); - // Each band's chip at the right edge, as wide as its own text: a click - // finds it whether or not a frame has drawn it. + // Each band's chip at the right edge, as wide as its own text and a + // blank cell either side, the pane's width at most: a click finds it + // whether or not a frame has drawn it. An overlay over the body's top + // rows, not a row taken from them, it is counted in GRID columns, not + // the tagline face it is drawn in: the grid is what a terminal client + // draws, and a chip narrower than its text there would clip it. const tx = r.x + config.GUTTER; const tw = r.w -| config.GUTTER; var leader_buf: [16]u8 = undefined; for (0..pane.notices.len) |i| { - const chip = noticeCols(p, noticeText(p, pane, i, &leader_buf), tw); - pane.notices.left[i] = if (chip == 0) std.math.maxInt(u16) else tx + tw - chip; + const chip = panes.File.displayWidth(noticeText(p, pane, i, &leader_buf)) + 2; + pane.notices.left[i] = if (tw == 0) std.math.maxInt(u16) else tx + tw - @as(u16, @intCast(@min(chip, tw))); } } |
