summaryrefslogtreecommitdiff
path: root/core
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
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')
-rw-r--r--core/Core.zig19
-rw-r--r--core/Kind.zig3
-rw-r--r--core/Layer.zig3
-rw-r--r--core/Messages.zig208
-rw-r--r--core/draw.zig94
-rw-r--r--core/layout.zig30
-rw-r--r--core/mouse.zig21
-rw-r--r--core/ninep/ctl.zig2
-rw-r--r--core/panes.zig5
-rw-r--r--core/replica.zig4
-rw-r--r--core/root.zig6
-rw-r--r--core/surface.zig3
12 files changed, 262 insertions, 136 deletions
diff --git a/core/Core.zig b/core/Core.zig
index a4c1d086..27a0da4f 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -2611,28 +2611,23 @@ test "TreeContext rows in the tag style keep the message rows" {
const full_height = p.surface.body_layers[0].viewport.h;
try std.testing.expect(p.surface.body_layers[0].rows > full_height);
try std.testing.expectEqual(FontRole.tagline, p.surface.body_layers[0].cells[0].style.font_role);
+ // A message is on the notice row, not over the body: the viewport
+ // keeps every row it had.
_ = Messages.keep(p, .notice, pane.serial, "", "!");
p.sync();
_ = try p.render(p.scratch.allocator());
- // An overlay takes nothing: the message is a chip OVER the body's first
- // row, so the viewport keeps every row it had.
try std.testing.expectEqual(full_height, p.surface.body_layers[0].viewport.h);
+ // ...and the leader's chip is an overlay that takes nothing either.
const r = p.view().rects[0];
+ p.view().prefix = .leader;
+ p.sync();
+ _ = try p.render(p.scratch.allocator());
+ try std.testing.expectEqual(full_height, p.surface.body_layers[0].viewport.h);
const band = for (p.surface.tagLayers()) |*layer| {
if (layer.rows != 0 and layer.kind == .notice) break layer;
} else return error.NoNoticeBand;
try std.testing.expectEqual(p.bodyTop(pane, r), band.viewport.y);
- try std.testing.expectEqual(p.surface.body_layers[0].viewport.y, band.viewport.y);
- // Sized to its message, flush with the pane's right edge, and the text
- // right aligned a cell short of that edge.
try std.testing.expectEqual(r.x + r.w, band.viewport.x + band.viewport.w);
- try std.testing.expect(band.viewport.w < r.w - config.GUTTER);
- try std.testing.expectEqualStrings("!", band.cells[layout.tagCapacity(p, band.viewport.w) - 2].grapheme());
- p.messages.live_len = 0;
- p.view().prefix = .leader;
- p.sync();
- _ = try p.render(p.scratch.allocator());
- try std.testing.expectEqual(full_height, p.surface.body_layers[0].viewport.h);
p.view().prefix = .none;
}
diff --git a/core/Kind.zig b/core/Kind.zig
index 764b6f06..806cd858 100644
--- a/core/Kind.zig
+++ b/core/Kind.zig
@@ -312,6 +312,9 @@ pub fn reopen(p: *Pardes, id: usize, s: *Slot, bytes: ?[]const u8) bool {
s.tail.len = @intCast(w.buffered().len);
}
s.opened = if (bytes) |b| std.hash.Wyhash.hash(0, b) else 0;
+ // A state made afresh is told every view afresh: the views told the
+ // one before (a file changed on disk, a Restore) are not its.
+ s.views = @splat(0);
// Its file not read (not here): it waits for it, a placeholder.
if (s.ops != null and bytes == null and s.path.len > 0) _ = cl.refused.print("{s} is not here", .{s.path}) else if (s.ops) |ops| {
const path_z = s.arena.allocator().dupeSentinel(u8, s.path, 0) catch "";
diff --git a/core/Layer.zig b/core/Layer.zig
index 8128543a..79552631 100644
--- a/core/Layer.zig
+++ b/core/Layer.zig
@@ -20,7 +20,8 @@ const Layer = @This();
/// chord -- carried as a tagline-shaped band so it gets the tagline's height,
/// small-font metrics, band offset and border instead of being a body-grid row
/// wearing a tagline font.
-pub const Kind = enum(u8) { workspace, column, pane, notice, body };
+/// `notice_row` is the window's foot row, the live messages' index.
+pub const Kind = enum(u8) { workspace, column, pane, notice, body, notice_row };
pub const Metrics = struct {
body_w: u16 = 1,
diff --git a/core/Messages.zig b/core/Messages.zig
index 747e5e2f..b4950b4f 100644
--- a/core/Messages.zig
+++ b/core/Messages.zig
@@ -2,8 +2,9 @@
//! word a Look understands, its text, the places it names and the lines
//! that explain it, kept in a fixed list while it lives; the log of
//! everything said behind them (the history, `SPC h m`, and 9P `/log`);
-//! and the transient bands a pane shows over its body's top rows (the
-//! pending leader chord, a prompt waiting for input).
+//! the notice row at the window's foot that indexes them; and the
+//! transient bands a pane shows over its body's top rows (the pending
+//! leader chord, a prompt waiting for input).
const pardes = @import("root.zig");
const memory = @import("memory.zig");
const std = @import("std");
@@ -277,7 +278,7 @@ pub fn say(p: *Pardes, kind: Kind, id: usize, text: []const u8) void {
const pane: ?*Pane = if (id < MAX_PANES and !p.fs.session_write) p.panes[id] else null;
var src: Buf(96) = .{};
if (pane) |cause| {
- if (cause.file) |f| src.set(f.path) else if (cause.command) |line| {
+ if (cause.file) |f| src.set(f.path) else if (if (cause.addon) |k| k.path.len > 0 else false) src.set(cause.addon.?.path) else if (cause.command) |line| {
const first = line[0 .. std.mem.indexOfAny(u8, line, "\r\n") orelse line.len];
var cut = @min(first.len, 64);
while (cut < first.len and cut > 0 and first[cut] & 0xC0 == 0x80) cut -= 1;
@@ -407,11 +408,80 @@ pub fn dimDue(p: *const Pardes) ?u64 {
return soonest;
}
+/// The notice row's line (SPEC §10.3), `width` columns: on the left the
+/// message the row leads with (`headline`), its glyph, its cause, its
+/// words, `×n` and the places it names; on the right how many more live,
+/// the questions waiting, or the way to the history. With nothing live the
+/// left says where the focused pane's caret is. Built each frame from the
+/// state, in `out`.
+pub const Row = struct {
+ /// The left part's end and the right part's start, in bytes of `text`.
+ left: usize = 0,
+ right: usize = 0,
+ text: []const u8 = "",
+};
+
+/// Room for the notice row's line: the widest window's at the tagline's
+/// pitch (Layer.capacity) is cut to it.
+pub const notice_row_cap = 1024;
+
+pub fn noticeRow(p: *const Pardes, width: usize, out: *[notice_row_cap]u8) Row {
+ const m = &p.messages;
+ var w: std.Io.Writer = .fixed(out);
+ var live: usize = 0;
+ var questions: usize = 0;
+ for (m.live[0..m.live_len]) |*s| {
+ if (s.kind == .progress) continue;
+ live += 1;
+ if (s.kind == .question) questions += 1;
+ }
+ const lead = m.headline();
+ if (lead) |s| {
+ w.print("{s} ", .{s.kind.glyph()}) catch {};
+ // Its cause first, unless its words name it already.
+ const words = s.words();
+ if (s.src.len > 0 and std.mem.indexOf(u8, words, s.src.slice()) == null) w.print("{s} ", .{s.src.slice()}) catch {};
+ w.writeAll(words) catch {};
+ if (s.n > 1) w.print(" \u{d7}{d}", .{s.n}) catch {};
+ for (s.places[0..s.places_len], 0..) |*place, i| w.print("{s} {s}:{d}:{d}", .{ if (i > 0) " \u{b7}" else "", place.path.slice(), place.line, place.col }) catch {};
+ } else if (p.panes[p.view().active]) |pane| {
+ if (pane.file) |f| w.print("{s}:{d}", .{ f.path, pane.body.cur_row + 1 }) catch {} else w.writeAll(pane.cwdSlice()) catch {};
+ }
+ const left_end = w.end;
+ var right: [64]u8 = undefined;
+ var r: std.Io.Writer = .fixed(&right);
+ if (live > 1) r.print("+{d} \u{b7} ", .{live - 1}) catch {};
+ if (questions > 0)
+ r.print("{d} question{s} \u{b7} SPC e", .{ questions, if (questions == 1) "" else "s" }) catch {}
+ else if (lead != null and lead.?.kind == .@"error" and lead.?.places_len > 0)
+ r.writeAll("SPC e walk") catch {}
+ else if (m.len > 0)
+ r.print("{d} message{s} \u{b7} SPC h m", .{ m.len, if (m.len == 1) "" else "s" }) catch {};
+ const tail = r.buffered();
+ // The left cut to make room for the right, a blank between them.
+ const tab = p.settings.tab;
+ const tail_w = panes.File.displayWidth(tab, tail);
+ const room = width -| (tail_w + 1);
+ var cut = left_end;
+ if (panes.File.displayWidth(tab, out[0..cut]) > room) {
+ cut = panes.File.rawAtDisplay(tab, out[0..left_end], room);
+ while (cut > 0 and panes.File.displayWidth(tab, out[0..cut]) > room) {
+ cut -= 1;
+ while (cut > 0 and out[cut] & 0xC0 == 0x80) cut -= 1;
+ }
+ }
+ w.end = cut;
+ const gap = width -| (panes.File.displayWidth(tab, out[0..cut]) + tail_w);
+ for (0..gap) |_| w.writeByte(' ') catch {};
+ const right_at = w.end;
+ w.writeAll(tail) catch {};
+ return .{ .left = cut, .right = right_at, .text = w.buffered() };
+}
+
/// What notice band `i` says. The grid pass and the band layers both
/// read it here, so a terminal and a pixel shell show the same line.
pub fn noticeText(p: *const Pardes, pane: *const Pane, i: usize, leader_buf: *[16]u8) []const u8 {
return switch (pane.notices.kinds[i]) {
- .message => p.messages.saidBy(pane),
.leader => leaderText(p, leader_buf),
.prompt => pane.promptText() orelse "",
};
@@ -603,8 +673,6 @@ pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void {
pub fn bands(p: *const Pardes, v: *const Pardes.View, pane: *const Pane, tag_rows: u16, r: Rect, id: usize) Pane.Notices {
var n: Pane.Notices = .{};
if (r.w <= config.GUTTER or r.h <= tag_rows) return n;
- // The newest message said of it on top.
- if (p.messages.saidBy(pane).len > 0) n.push(.message);
if (id == v.active and v.prefix == .leader) n.push(.leader);
// Del's question shows once its delay is up: answered before that, it
// was never there.
@@ -769,7 +837,7 @@ test "an echo or a notice retires those before it, an error the error before it,
try std.testing.expectEqualStrings("w3", m.live[0].text.slice());
}
-test "a builtin announces itself on the message row, and Verbose silences it" {
+test "a builtin announces itself on the notice row, an echo, and Verbose silences it" {
if (pardes.Term.ops == null) return error.SkipZigTest; // a terminal's tag row
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
defer p.deinit();
@@ -777,39 +845,35 @@ test "a builtin announces itself on the message row, and Verbose silences it" {
p.sync();
try std.testing.expect(p.settings.verbose);
- // Wrap, not Collapse: a builtin that folds its own pane away leaves no row
- // for its announcement, which is correct and not what this is testing.
+ // Wrap, not Collapse: a builtin that folds its own pane away is not
+ // what this is testing.
try std.testing.expect(p.executeBuiltinLine(p.view().active, "Wrap"));
try std.testing.expectEqualStrings("Wrap", p.messages.saidBy(pane));
- // A value it does not take is said, in place of the announcement.
+ try std.testing.expectEqual(Kind.echo, p.messages.headline().?.kind);
+ // A value it does not take is said, an error, and leads the row.
const wrapped = p.settings.wrap;
try std.testing.expect(p.executeBuiltinLine(p.view().active, "Wrap maybe"));
try std.testing.expectEqualStrings("Wrap: takes on, off", p.messages.saidBy(pane));
try std.testing.expectEqual(wrapped, p.settings.wrap);
- // The notice list is what the paint pass reads, so the announcement has to
- // reach it, not just the buffer.
- collectNotices(p, pane, p.view().rects[p.view().active], p.view().active);
- try std.testing.expect(pane.notices.len > 0);
- try std.testing.expectEqual(Pane.Notices.Kind.message, pane.notices.kinds[0]);
-
- // ...and it is carried as a tagline band, not a body row: that is what
- // gives it the tagline's height, its small font and its border.
+ // ...on the window's foot row, a tagline-shaped layer, not on a chip
+ // over the pane's body.
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
- _ = try p.render(frame.allocator());
- const r = p.view().rects[p.view().active];
- const band = for (p.surface.tagLayers()) |*layer| {
- if (layer.rows != 0 and layer.kind == .notice) break layer;
- } else return error.NoNoticeBand;
- try std.testing.expectEqual(@as(u16, 1), band.viewport.h);
- try std.testing.expectEqual(r.y + BOX_H, band.viewport.y);
- // Right aligned: the text ends at the band's right edge.
- const line = band.cells[0..band.cols];
- var last: usize = line.len;
- while (last > 0 and line[last - 1].grapheme()[0] == ' ') last -= 1;
- try std.testing.expect(last > 0);
- try std.testing.expect(line[0].grapheme()[0] == ' ');
+ const s = try p.render(frame.allocator());
+ try std.testing.expectEqual(@as(u8, 0), pane.notices.len);
+ const row = for (s.tagLayers()) |*layer| {
+ if (layer.rows != 0 and layer.kind == .notice_row) break layer;
+ } else return error.NoNoticeRow;
+ try std.testing.expectEqual(@as(u16, 1), row.viewport.h);
+ try std.testing.expectEqual(p.view().screen_h - 1, row.viewport.y);
+ var want: [64]u8 = undefined;
+ const said = try std.fmt.bufPrint(&want, "\u{2717} @p{d} Wrap: takes on, off", .{pane.serial});
+ const grid = s.cells[@as(usize, row.viewport.y) * s.cols ..][0..s.cols];
+ var text: std.ArrayList(u8) = .empty;
+ defer text.deinit(std.testing.allocator);
+ for (grid) |cell| try text.appendSlice(std.testing.allocator, cell.grapheme());
+ try std.testing.expect(std.mem.indexOf(u8, text.items, said) != null);
// Msg owns the row itself, so it does not announce over its own text.
try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg hello"));
@@ -821,52 +885,48 @@ test "a builtin announces itself on the message row, and Verbose silences it" {
try std.testing.expectEqual(@as(usize, 0), p.messages.saidBy(pane).len);
}
-test "notices stack over the body's top rows without moving them" {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
+test "the notice row leads with the most important live message, its count and places, and says how many more; with none, where the caret is" {
+ const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 });
defer p.deinit();
+ const pane = try p.setTestFile("one\ntwo\nthree\n");
const id = p.view().active;
- const pane = p.panes[id].?;
- p.sync();
- var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer frame.deinit();
-
- const r = p.view().rects[id];
- const top = p.bodyTop(pane, r);
-
- // A message and a leader prefix at once: two chips, in the order
- // collectNotices chose, each one row tall and each one row further down.
- try std.testing.expect(p.executeBuiltinLine(id, "Msg first"));
- p.view().prefix = .leader;
- p.view().leader_n = 0;
- _ = frame.reset(.retain_capacity);
- _ = try p.render(frame.allocator());
- try std.testing.expectEqual(@as(u8, 2), pane.notices.len);
- // An overlay, not a reservation: the body still starts where it did.
- try std.testing.expectEqual(top, p.bodyTop(pane, r));
-
- var seen: usize = 0;
- for (p.surface.tagLayers()) |*layer| {
- if (layer.rows == 0 or layer.kind != .notice) continue;
- try std.testing.expectEqual(@as(u16, 1), layer.viewport.h);
- // Sized to its own message, right up against the pane's right edge --
- // not the width of the pane.
- try std.testing.expectEqual(r.x + r.w, layer.viewport.x + layer.viewport.w);
- try std.testing.expect(layer.viewport.w < r.w - config.GUTTER);
- try std.testing.expect(layer.viewport.y == top or layer.viewport.y == top + 1);
- try std.testing.expectEqual(pane.notices.left[layer.viewport.y - top], layer.viewport.x);
- seen += 1;
- }
- try std.testing.expectEqual(@as(usize, 2), seen);
- // "first" is longer than "SPC", so its chip is wider.
- try std.testing.expect(pane.notices.left[0] < pane.notices.left[1]);
-
- // Gone with the notices: no stale chip left behind.
- p.view().prefix = .none;
p.messages.live_len = 0;
- _ = frame.reset(.retain_capacity);
- _ = try p.render(frame.allocator());
- for (p.surface.tagLayers()) |*layer|
- try std.testing.expect(layer.rows == 0 or layer.kind != .notice);
+ p.messages.len = 0;
+ pane.body.cur_row = 1;
+ var buf: [notice_row_cap]u8 = undefined;
+ var row = noticeRow(p, 60, &buf);
+ try std.testing.expectEqualStrings("/test.txt:2", row.text[0..row.left]);
+ try std.testing.expectEqual(@as(usize, 60), panes.File.displayWidth(p.settings.tab, row.text));
+ // A notice, then an error and a warning: the error leads, newest first
+ // within a rank; the others are counted.
+ say(p, .notice, id, "indexed");
+ say(p, .warn, id, "careful");
+ say(p, .@"error", id, "broke");
+ row = noticeRow(p, 60, &buf);
+ try std.testing.expectEqualStrings("\u{2717} /test.txt broke", row.text[0..row.left]);
+ try std.testing.expect(std.mem.endsWith(u8, row.text, "+1 \u{b7} 3 messages \u{b7} SPC h m"));
+ // A burst of the same: one message, counted; the row keeps its width.
+ for (0..9) |_| say(p, .@"error", id, "broke");
+ row = noticeRow(p, 60, &buf);
+ try std.testing.expectEqualStrings("\u{2717} /test.txt broke \u{d7}10", row.text[0..row.left]);
+ try std.testing.expectEqual(@as(usize, 60), panes.File.displayWidth(p.settings.tab, row.text));
+ // An error that names places offers the walk, its places as words.
+ const err = keep(p, .@"error", 0, "@p9 zig build", "exit 1");
+ err.places[0] = .{ .line = 25, .col = 12 };
+ err.places[0].path.set("core/pick.zig");
+ err.places_len = 1;
+ row = noticeRow(p, 80, &buf);
+ try std.testing.expectEqualStrings("\u{2717} @p9 zig build exit 1 core/pick.zig:25:12", row.text[0..row.left]);
+ try std.testing.expect(std.mem.endsWith(u8, row.text, "+1 \u{b7} SPC e walk"));
+ // Too narrow: the left gives way, the right stays whole.
+ row = noticeRow(p, 30, &buf);
+ try std.testing.expect(std.mem.endsWith(u8, row.text, "+1 \u{b7} SPC e walk"));
+ try std.testing.expect(panes.File.displayWidth(p.settings.tab, row.text) <= 30);
+ // A question outranks a warning, not an error; it is counted on the right.
+ _ = keep(p, .question, pane.serial, "/test.txt", "changed on disk");
+ row = noticeRow(p, 80, &buf);
+ try std.testing.expect(std.mem.startsWith(u8, row.text, "\u{2717} @p9"));
+ try std.testing.expect(std.mem.endsWith(u8, row.text, "+2 \u{b7} 1 question \u{b7} SPC e"));
}
test "an idle core wants no wake, and a message wakes it once, when it dims" {
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());
}
}
diff --git a/core/layout.zig b/core/layout.zig
index 7fa57ee9..ff14a789 100644
--- a/core/layout.zig
+++ b/core/layout.zig
@@ -613,7 +613,7 @@ pub fn minRows(p: *Pardes, id: usize) u16 {
pub fn minimaFit(p: *Pardes) bool {
const v = p.view();
compute(p);
- const avail = v.screen_h -| (p.topBarHeight() + columnBarHeight(p));
+ const avail = v.screen_h -| (p.topBarHeight() + columnBarHeight(p) + noticeRowHeight(p));
for (0..p.view().ncol) |c| {
if (v.cols[c].n < 2) continue;
var need: u32 = 0;
@@ -647,7 +647,7 @@ pub fn shareColumn(p: *Pardes, c: usize) bool {
compute(p);
const n = v.cols[c].n;
if (n == 0) return false;
- const avail = v.screen_h -| (p.topBarHeight() + columnBarHeight(p));
+ const avail = v.screen_h -| (p.topBarHeight() + columnBarHeight(p) + noticeRowHeight(p));
var mins: [MAX_PANES]u16 = undefined;
var need: u32 = 0;
for (v.cols[c].panes[0..n], 0..) |k, i| {
@@ -1333,7 +1333,8 @@ pub fn expandedNeighbor(p: *const Pardes, col: usize, index: usize, side: enum {
fn computeCollapsedColumn(p: *Pardes, c: usize, x: u16, width: u16, folded: usize) void {
const v = p.view();
var y: u16 = p.topBarHeight() + columnBarHeight(p);
- const available = v.screen_h -| y;
+ const bottom = v.screen_h -| noticeRowHeight(p);
+ const available = bottom -| y;
var expanded_left: usize = 0;
var weight: f32 = 0;
for (v.cols[c].panes[0..p.view().cols[c].n]) |id| if (p.panes[id]) |pane| {
@@ -1347,7 +1348,7 @@ fn computeCollapsedColumn(p: *Pardes, c: usize, x: u16, width: u16, folded: usiz
var folded_left = folded;
for (v.cols[c].panes[0..p.view().cols[c].n]) |id| {
const pane = p.panes[id] orelse continue;
- const room = v.screen_h -| y;
+ const room = bottom -| y;
const height: u16 = if (pane.collapsed) blk: {
folded_left -= 1;
break :blk @min(room, BOX_H);
@@ -1401,7 +1402,8 @@ pub fn compute(p: *Pardes) void {
var y: u16 = p.topBarHeight() + columnBarHeight(p);
const top = y;
- const avail_h = v.screen_h -| y;
+ const bottom = v.screen_h -| noticeRowHeight(p);
+ const avail_h = bottom -| y;
var hs: [MAX_PANES]u16 = undefined;
const n = v.cols[c].n;
for (0..n) |k| {
@@ -1412,7 +1414,7 @@ pub fn compute(p: *Pardes) void {
};
const lastk = k + 1 == n;
const fh = @as(f32, @floatFromInt(avail_h)) * pane.vweight / vsum;
- const room = v.screen_h -| y;
+ const room = bottom -| y;
hs[k] = if (lastk) room else @min(room, @max(1, @as(u16, @intFromFloat(@round(fh)))));
y +|= hs[k];
}
@@ -1471,6 +1473,14 @@ pub fn topBarHeight(p: *const Pardes) u16 {
return TOPBAR_H;
}
+/// The notice row's height: one row at the window's foot (pick-ui SPEC
+/// §10.3), the index of the live messages, under every column; none on a
+/// screen too short for it, as the column tags have none.
+pub fn noticeRowHeight(p: *const Pardes) u16 {
+ if (p.view().screen_h < 3) return 0;
+ return 1;
+}
+
/// The column tags' height: one row, as acme's (cols.c:244, colresize,
/// gives a column tag one font height); a newline in one is a space
/// (tagline.flattenHeaders).
@@ -1668,14 +1678,14 @@ test "collapse transfers height upward and restores the original layout" {
toggleCollapse(p, 1);
try std.testing.expectEqual(@as(u16, 1), p.view().rects[1].h);
try std.testing.expectEqual(@as(f32, @floatFromInt(original[1].h)), p.panes[1].?.vweight);
- try std.testing.expectEqual(p.view().screen_h, p.view().rects[2].y + p.view().rects[2].h);
+ try std.testing.expectEqual(p.view().screen_h - noticeRowHeight(p), p.view().rects[2].y + p.view().rects[2].h);
try std.testing.expect(p.view().rects[0].h > original[0].h);
try std.testing.expectEqualDeep(original[2], p.view().rects[2]);
toggleCollapse(p, 1);
try std.testing.expectEqualDeep(original, p.view().rects);
toggleCollapse(p, 2);
try std.testing.expectEqual(@as(u16, 1), p.view().rects[2].h);
- try std.testing.expectEqual(p.view().screen_h, p.view().rects[2].y + p.view().rects[2].h);
+ try std.testing.expectEqual(p.view().screen_h - noticeRowHeight(p), p.view().rects[2].y + p.view().rects[2].h);
}
test "collapse changes only one neighbor at the top middle and bottom" {
@@ -1793,7 +1803,7 @@ test "collapse single and all panes leave unused column space" {
try std.testing.expectEqual(p.view().rects[0].y + 1, p.view().rects[1].y);
try std.testing.expect(p.view().rects[1].y + 1 < p.view().screen_h);
toggleCollapse(p, 0);
- try std.testing.expectEqual(p.view().screen_h - 1, p.view().rects[1].y);
+ try std.testing.expectEqual(p.view().screen_h - noticeRowHeight(p) - 1, p.view().rects[1].y);
}
test "collapse survives tiny resizes" {
@@ -1854,7 +1864,7 @@ test "collapse dump restores folded state and retained expansion weight" {
try std.testing.expectEqual(@as(f32, @floatFromInt(original_height)), restored.panes[0].?.vweight);
try std.testing.expectEqual(@as(u16, 1), restored.view().rects[0].h);
toggleCollapse(restored, 0);
- try std.testing.expectEqual(restored.view().screen_h - restored.view().rects[0].y, restored.view().rects[0].h);
+ try std.testing.expectEqual(restored.view().screen_h - noticeRowHeight(restored) - restored.view().rects[0].y, restored.view().rects[0].h);
}
test "column reorder moves only crossed state and preserves weights" {
diff --git a/core/mouse.zig b/core/mouse.zig
index ad76c313..aab8a752 100644
--- a/core/mouse.zig
+++ b/core/mouse.zig
@@ -581,6 +581,21 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
v.hover_col = mcol;
v.hover_row = mrow;
+ // The notice row: the execute or the look button on a word there runs
+ // it or Looks at it, as on a header (a place a message names, its
+ // cause); nothing else happens on it.
+ const foot = layout.noticeRowHeight(p);
+ if (foot > 0 and mrow >= v.screen_h - foot and v.drag == .none and v.header_sweep == null and !v.header_drag) {
+ if (m.kind != .press or (m.button != config.exec_button and m.button != config.look_button)) return;
+ var buf: [pardes.Messages.notice_row_cap]u8 = undefined;
+ const row = pardes.Messages.noticeRow(p, layout.tagCapacity(p, v.screen_w -| TAG_TEXT_INSET) -| 1, &buf);
+ const col = Layer.columnAt(p, .notice_row, 0, v.pointer_tag_hit, false, 0) orelse (mcol -| TAG_TEXT_INSET);
+ const bounds = tagline.wordBoundsAtCol(row.text, panes.File.rawAtDisplay(p.settings.tab, row.text, col)) orelse return;
+ const word = p.scratch.allocator().dupe(u8, row.text[bounds.lo..bounds.hi]) catch |err| return p.reportError(.at(v.active), "notice row", err);
+ if (m.button == config.exec_button) _ = exec.execute(p, v.active, word) else exec.runBuiltin(p, config.look_cmd, v.active, "", word);
+ return;
+ }
+
const hovered = paneAt(p, mcol, mrow);
// any press that is NOT the execute+select chord abandons a pending
@@ -938,9 +953,9 @@ pub fn dragUpdate(p: *Pardes, mcol: u16, mrow: u16, body_hit: ?Mouse.BodyHit) vo
else if (mrow < body_y)
-1
else if (mrow >= body_y + body_h or
- // The pointer cannot leave the screen: at a bottom pane,
- // its last row is the edge.
- (body_y + body_h >= v.screen_h and mrow + 1 >= body_y + body_h))
+ // The pointer cannot leave the screen: at a bottom pane
+ // (over the notice row), its last row is the edge.
+ (body_y + body_h + layout.noticeRowHeight(p) >= v.screen_h and mrow + 1 >= body_y + body_h))
1
else
0;
diff --git a/core/ninep/ctl.zig b/core/ninep/ctl.zig
index 033a9808..c7f22b9a 100644
--- a/core/ninep/ctl.zig
+++ b/core/ninep/ctl.zig
@@ -2264,7 +2264,7 @@ test "a column takes panes until their documented minimums fill it, not until no
const new = @backingInt(tree.TopFile.new);
while (call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status == .ok) p.sync();
p.sync();
- const avail = p.view().screen_h - (p.topBarHeight() + layout.columnBarHeight(p));
+ const avail = p.view().screen_h - (p.topBarHeight() + layout.columnBarHeight(p) + layout.noticeRowHeight(p));
for (0..p.view().ncol) |c| {
var need: u32 = 0;
for (p.view().cols[c].panes[0..p.view().cols[c].n]) |k| need += layout.minRows(p, k);
diff --git a/core/panes.zig b/core/panes.zig
index 146b1360..ea0ff86d 100644
--- a/core/panes.zig
+++ b/core/panes.zig
@@ -346,8 +346,7 @@ pub const Pane = struct {
ovl: ?Text.EditBuffer = null,
tty_filter: bool = false,
/// The transient lines this pane shows between its body and its tagline:
- /// the newest message said of it, the pending leader chord, a prompt
- /// waiting for input. Rebuilt every frame from the state that owns each one, so a
+ /// the pending leader chord, a prompt waiting for input. Rebuilt every frame from the state that owns each one, so a
/// line that goes away is simply not added again and the rest close the
/// gap -- there is no second copy of the truth to fall out of step. The
/// body layer reserves exactly `len` rows for them, the way it already
@@ -381,7 +380,7 @@ pub const Pane = struct {
pub const Notices = struct {
/// Painted bottom-up in this order, so a prompt keeps the row nearest
/// the tagline that it has always had, and its cursor with it.
- pub const Kind = enum { message, leader, prompt };
+ pub const Kind = enum { leader, prompt };
pub const max = @typeInfo(Kind).@"enum".field_names.len;
kinds: [max]Kind = undefined,
diff --git a/core/replica.zig b/core/replica.zig
index 2a66cc3d..42ce3487 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -7998,7 +7998,7 @@ test "a far client's drag in a kind's pane it grabbed, the pane since too short
}
for ([_]pardes.Event{
.{ .mouse = .{ .button = .left, .kind = .press, .col = col, .row = row } },
- .{ .resize = .{ .cols = 80, .rows = 4 } },
+ .{ .resize = .{ .cols = 80, .rows = 5 } },
.{ .mouse = .{ .button = .left, .kind = .drag, .col = col, .row = 30 } },
.{ .mouse = .{ .button = .left, .kind = .release, .col = col, .row = 30 } },
}) |ev| {
@@ -8395,7 +8395,7 @@ test "a far client's replay of a message its session's host stamped takes the se
r.confirm(u);
r.settle();
try agrees(a, r);
- try std.testing.expect(try shows(r.core(), "--:--:-- yanked x"));
+ try std.testing.expectEqualStrings("--:--:-- yanked x", r.core().messages.headline().?.text.slice());
}
// A script's `pty/run` in a shell (ninep/pty.zig): the open, the line, the
diff --git a/core/root.zig b/core/root.zig
index c7163400..5c49a038 100644
--- a/core/root.zig
+++ b/core/root.zig
@@ -139,8 +139,10 @@ pub const TagKind = Layer.Kind;
pub const MAX_TAG_ROWS = 8;
/// Panes, then columns, then the workspace bar, then each pane's notice
/// bands: a band to a tag, however many lines it has.
-pub const MAX_TAG_LAYERS = MAX_PANES + MAX_COLS + 1 + MAX_PANES * Pane.Notices.max;
-pub const NOTICE_LAYER_BASE = MAX_PANES + MAX_COLS + 1;
+pub const MAX_TAG_LAYERS = MAX_PANES + MAX_COLS + 2 + MAX_PANES * Pane.Notices.max;
+/// The notice row's layer, after the workspace tag's.
+pub const NOTICE_ROW_LAYER = MAX_PANES + MAX_COLS + 1;
+pub const NOTICE_LAYER_BASE = MAX_PANES + MAX_COLS + 2;
/// Columns a session holds (each costs about 8 KB of state, a column tag
/// being most of it).
pub const MAX_COLS = 16;
diff --git a/core/surface.zig b/core/surface.zig
index 98696721..7c04a387 100644
--- a/core/surface.zig
+++ b/core/surface.zig
@@ -98,6 +98,9 @@ pub const Region = struct {
column_grip,
column_tag,
workspace_tag,
+ /// The row at the window's foot that indexes the live messages
+ /// (Messages.noticeRow).
+ notice_row,
/// A column below the workspace tag, its bar and panes: its left
/// edge is the spine a pixel shell rules down it.
column,