summaryrefslogtreecommitdiff
path: root/core/draw.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 19:28:29 -0300
committerGabriel Schneider <[email protected]>2026-11-24 20:02:56 -0300
commitc40d447e63663d947f241d60a2bdb8ce1bd141c0 (patch)
tree93dcd149384624306166f1a7a6b5d75b138ca27c /core/draw.zig
parentf26cf0be705280ff28ca69aaef6cc64e1466ed4e (diff)
downloadpardes-c40d447e63663d947f241d60a2bdb8ce1bd141c0.tar.gz
pardes-c40d447e63663d947f241d60a2bdb8ce1bd141c0.zip
messages: one notice row at the window's foot indexes the live messages, and the chips over the bodies go (pick-ui SPEC §10.3, walk UI line C item 2): the panes' area ends a row higher (layout.noticeRowHeight, none on a screen under 3 rows, as the column tags); the row is a header layer of its own (Layer.Kind.notice_row, NOTICE_ROW_LAYER, Region.Kind.notice_row) in the workspace tag's colours: on the left the message the row leads with (error > question > warn > notice > echo, the newest within a rank: its glyph in its kind's ink, its cause unless its words name it, its words without a host's clock stamp, ×n, its places as words), dimmed once its bright time is over; on the right +N more, N questions · SPC e, SPC e walk for an error with places, or N messages · SPC h m; with nothing live the focused pane's path:line (a terminal's directory); built each frame from the state (Messages.noticeRow, bounded by notice_row_cap), the left part giving way to the right; B2 runs and B3 Looks at a word on it (mouse.zig); Pane.Notices keeps the leader's and a prompt's chips only; a latent fault found by it: a kind's pane reopened (its file changed on disk, a Restore) kept the hashes of the views its old state was told, so the new state was never told its view and a PDF stayed blank until something moved its pane; the reloaded message's chip used to move it (Kind.reopen now tells a new state every view; behaviour addons_pdf's disk-change and Restore tests, failing before the fix); a message's cause for a kind's pane is its path; every frame changes (the foot row): boot's foot reads '/tmp/pardes-snap/boot/cwd', msg's 'repainted' '· saved /tmp/pardes-snap/msg/cwd/a.txt 2 messages · SPC h m' where a chip stood on the body's first row; the 98 tty goldens rewritten and read (57 the rows shifted alone, the rest the chips gone and racy shell output re-recorded; no file-written block and no snapshot's name changed), the four tty cases that click at fixed rows given a row more (chordcut, layout-open, images, respawn: their cursors unchanged), the addon scripts' outputs (fake, snake, life, pdf: windows a row shorter, the chip gone), hxdiff's core a row taller (22 rows as helix's), the tests over tiny screens a row taller, the drag edge of a bottom pane over the notice row (mouse.zig); tests: Messages.zig 'the notice row leads with the most important live message ...', 'a builtin announces itself on the notice row, an echo ...', draw.zig 'the word under the pointer on the notice row is lit ...', 'a message wider than the notice row ... gives way to the row's right end'; tui gate: core-test, pane-test, shell-test, behaviour-test (and --replay: 20 seeds, 0 failures), term-test, kitty-test pass; process-test 0 of 146 failed; the gui build is gated at the line's end
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/draw.zig')
-rw-r--r--core/draw.zig94
1 files changed, 66 insertions, 28 deletions
diff --git a/core/draw.zig b/core/draw.zig
index c3c80934..a7513468 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -160,10 +160,12 @@ pub fn place(p: *Pardes, s: *Surface) void {
const active_col = if (layout.findPane(p, v.active)) |found| found.col else null;
for (0..p.view().ncol) |c| {
if (v.col_w[c] == 0) continue;
- s.addRegion(.{ .kind = .column, .owner = @intCast(c), .serial = v.cols[c].serial, .active = active_col == c, .rect = .{ .x = v.col_x[c], .y = p.topBarHeight(), .w = v.col_w[c], .h = s.rows -| p.topBarHeight() } });
+ s.addRegion(.{ .kind = .column, .owner = @intCast(c), .serial = v.cols[c].serial, .active = active_col == c, .rect = .{ .x = v.col_x[c], .y = p.topBarHeight(), .w = v.col_w[c], .h = s.rows -| (p.topBarHeight() + layout.noticeRowHeight(p)) } });
}
if (p.settings.workspace_tag)
s.addRegion(.{ .kind = .workspace_tag, .rect = .{ .x = 0, .y = 0, .w = s.cols, .h = p.topBarHeight() } });
+ const foot = layout.noticeRowHeight(p);
+ if (foot > 0) s.addRegion(.{ .kind = .notice_row, .rect = .{ .x = 0, .y = s.rows - foot, .w = s.cols, .h = foot } });
}
/// A pane's grip in the grid: `box` focused, else halfway between its ring
@@ -346,7 +348,7 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
// Separators have their own role; a scrollbar need not frame the page.
const whole = s.regions[0].rect;
s.fill(whole.x, whole.y, whole.w, whole.h, .{ .bg = .{ .rgb = chrome.border } });
- for (0..p.view().ncol) |c| if (v.cols[c].n == 0) s.fill(v.col_x[c], p.topBarHeight() + layout.columnBarHeight(p), v.col_w[c], s.rows -| (p.topBarHeight() + layout.columnBarHeight(p)), .{ .bg = .{ .rgb = chrome.empty_col } });
+ for (0..p.view().ncol) |c| if (v.cols[c].n == 0) s.fill(v.col_x[c], p.topBarHeight() + layout.columnBarHeight(p), v.col_w[c], s.rows -| (p.topBarHeight() + layout.columnBarHeight(p) + layout.noticeRowHeight(p)), .{ .bg = .{ .rgb = chrome.empty_col } });
for (&p.panes, 0..) |*slot, id| {
const pane = slot.* orelse continue;
@@ -359,6 +361,7 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
}
try paintHeaders(p, s);
+ try paintNoticeRow(p, s);
// debug overlay: a small stats box drawn last, top-right ("Debug")
if (p.settings.debug) if (p.panes[v.active]) |at| {
@@ -572,6 +575,43 @@ fn paintHeaders(p: *Pardes, s: *Surface) !void {
};
}
+/// The notice row (Messages.noticeRow), the live messages' index at the
+/// window's foot: a header layer at the tagline's pitch in the workspace
+/// tag's colours, the glyph in its kind's, a message gone dim and the
+/// counts at the right end dimmed.
+fn paintNoticeRow(p: *Pardes, s: *Surface) !void {
+ const region = s.region(.notice_row, Region.none) orelse return;
+ const chrome = p.chromeTheme();
+ var viewport = region.rect;
+ const inset = @min(TAG_TEXT_INSET, viewport.w);
+ s.fill(viewport.x, viewport.y, inset, viewport.h, .{ .bg = .{ .rgb = chrome.tagline_bg }, .font_role = .tagline });
+ viewport.x += inset;
+ viewport.w -= inset;
+ var buf: [Messages.notice_row_cap]u8 = undefined;
+ const row = Messages.noticeRow(p, layout.tagCapacity(p, viewport.w) -| 1, &buf);
+ const layer = &s.tag_layers[pardes.NOTICE_ROW_LAYER];
+ try renderHeaderLayer(p, layer, .notice_row, 0, viewport, row.text, 0, chrome.tagline_bg, chrome.tagline_fg);
+ if (layer.rows == 0) return;
+ const dim: Color = .{ .rgb = colors.mix(chrome.tagline_fg, chrome.tagline_bg) };
+ const ink: Color = .{ .rgb = chrome.tagline_fg };
+ const cells = layer.cells[0..layer.cols];
+ const tab = p.settings.tab;
+ const left = @min(cells.len, panes.File.displayWidth(tab, row.text[0..row.left]));
+ const right = @min(cells.len, panes.File.displayWidth(tab, row.text[0..row.right]));
+ if (p.messages.headline()) |lead| {
+ if (lead.kind == .@"error" or lead.kind == .warn) if (cells.len > 0 and std.meta.eql(cells[0].style.fg, ink)) {
+ cells[0].style.fg = .{ .rgb = if (lead.kind == .@"error") chrome.diagnostic_error else chrome.diagnostic_warning };
+ };
+ if (lead.faded(p.clock.now_ns, p.settings.message_linger_ms)) for (cells[0..left]) |*cell| {
+ if (std.meta.eql(cell.style.fg, ink)) cell.style.fg = dim;
+ };
+ }
+ for (cells[right..]) |*cell| if (std.meta.eql(cell.style.fg, ink)) {
+ cell.style.fg = dim;
+ };
+ joinHeaderRows(s, layer, chrome.tagline_fg);
+}
+
/// Copy a header's layer into the grid under it, row by row, and its caret.
fn joinHeaderRows(s: *Surface, layer: *const pardes.Layer, fg: [3]u8) void {
const v = layer.viewport;
@@ -664,7 +704,7 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
const editing: ?*Text = if (v.header != null and switch (kind) {
.workspace => p.headerColumn() == null,
.column => p.headerColumn() == id,
- .pane, .notice, .body => false,
+ .pane, .notice, .body, .notice_row => false,
}) tagline.focusedHeader(p) else null;
const scroll = if (editing != null) v.header_scroll else 0;
for (0..viewport.h) |index| {
@@ -716,7 +756,7 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
const mine = switch (kind) {
.workspace => column == null,
.column => column == id,
- .pane, .notice, .body => false,
+ .pane, .notice, .body, .notice_row => false,
};
const swept = sweep.span(text.len);
const start = modal.lineStartOffset(text, index + top);
@@ -1131,8 +1171,8 @@ test "place puts every part where the painters and layers put it, in every layou
}
}
-test "the word under the pointer on a notice is lit in its layer and in the grid's copy" {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 41, .rows = 12 });
+test "the word under the pointer on the notice row is lit in its layer and in the grid's copy" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 61, .rows = 12 });
defer p.deinit();
_ = try p.setTestFile("text\n");
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
@@ -1140,36 +1180,35 @@ test "the word under the pointer on a notice is lit in its layer and in the grid
try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg Look here"));
p.sync();
var s = try p.render(arena.allocator());
- const notice = for (s.regionList()) |region| {
- if (region.kind == .notice) break region;
- } else return error.TestExpectedNotice;
- const row = s.cells[@as(usize, notice.rect.y) * s.cols ..][0..s.cols];
- // "here", the chip's last word, before its blank edge.
- const here = notice.rect.x + notice.rect.w - 5;
+ const foot = s.region(.notice_row, Region.none) orelse return error.TestExpectedNoticeRow;
+ try std.testing.expectEqual(s.rows - 1, foot.rect.y);
+ const row = s.cells[@as(usize, foot.rect.y) * s.cols ..][0..s.cols];
+ // "here": the message's last word, `· /test.txt Look here`, 17
+ // columns in.
+ const here: u16 = TAG_TEXT_INSET + 17;
try std.testing.expectEqualStrings("h", row[here].grapheme());
p.view().pointer_inside = true;
p.view().hover_col = here + 1;
- p.view().hover_row = notice.rect.y;
+ p.view().hover_row = foot.rect.y;
_ = arena.reset(.retain_capacity);
s = try p.render(arena.allocator());
- const lit = s.cells[@as(usize, notice.rect.y) * s.cols ..][0..s.cols];
- const sel: Color = .{ .rgb = p.theme().sel_bg };
+ const lit = s.cells[@as(usize, foot.rect.y) * s.cols ..][0..s.cols];
+ const sel: Color = .{ .rgb = p.theme().tag_sel_bg orelse p.theme().sel_bg };
for (lit[here..][0..4]) |cell| try std.testing.expectEqual(sel, cell.style.bg);
try std.testing.expect(!std.meta.eql(sel, lit[here - 2].style.bg));
- const layer = for (s.tagLayers()) |*layer| {
- if (layer.rows != 0 and layer.kind == .notice) break layer;
- } else return error.TestExpectedNotice;
+ const layer = &s.tag_layers[pardes.NOTICE_ROW_LAYER];
+ try std.testing.expectEqual(TagKind.notice_row, layer.kind);
const lit_in_layer = for (layer.cells) |cell| {
if (std.meta.eql(sel, cell.style.bg)) break true;
} else false;
try std.testing.expect(lit_in_layer);
}
-test "a notice wider than its band, as a shader's compile error is, draws its end and nothing past it" {
+test "a message wider than the notice row, as a shader's compile error is, gives way to the row's right end and draws nothing past the row" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 20 });
defer p.deinit();
- // A gui-shaped core: its tagline is narrower than the body, so a notice's
- // band holds more columns than its chip has cells.
+ // A gui-shaped core: its tagline is narrower than the body, so the
+ // row's layer holds more columns than the grid has cells.
p.update(.{ .resize = .{ .cols = 80, .rows = 20, .row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 6, .tagline_h = 12 } } });
_ = try p.setTestFile("text\n");
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
@@ -1182,13 +1221,12 @@ test "a notice wider than its band, as a shader's compile error is, draws its en
for (0..30) |_| p.update(.tick);
_ = arena.reset(.retain_capacity);
const s = try p.render(arena.allocator());
- const notice = for (s.regionList()) |region| {
- if (region.kind == .notice) break region;
- } else return error.TestExpectedNotice;
- // Text up to the chip's blank last cell, and no padding ink.
- const row = s.cells[@as(usize, notice.rect.y) * s.cols ..][notice.rect.x..][0..notice.rect.w];
- try std.testing.expectEqualStrings(" ", row[row.len - 1].grapheme());
- try std.testing.expect(!std.mem.eql(u8, " ", row[row.len - 2].grapheme()));
+ const layer = &s.tag_layers[pardes.NOTICE_ROW_LAYER];
+ try std.testing.expectEqual(layout.tagCapacity(p, s.cols - TAG_TEXT_INSET), layer.cols);
+ // The counts at the row's end, whole, a blank cell short of it.
+ const cells = layer.cells[0..layer.cols];
+ try std.testing.expectEqualStrings(" ", cells[cells.len - 1].grapheme());
+ try std.testing.expectEqualStrings("m", cells[cells.len - 2].grapheme());
}
}