summaryrefslogtreecommitdiff
path: root/src/Messages.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 02:56:53 -0300
committerGabriel Schneider <[email protected]>2026-11-06 04:13:33 -0300
commitd1d5d3cfb18841604bba2057eeb3598f729b4475 (patch)
tree298c29ab8767852bf74eb86ad4d15acc4348f109 /src/Messages.zig
parent33037ece5af9ae1c7048819bbbae3fc5e6fc4ade (diff)
downloadpardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.tar.gz
pardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.zip
client #1, the views indexed: a view's share of the session is Pardes.View (the ~42 fields views.fields named: size, cell metrics, columns, rects, focus, jumps, pointer, gestures, prefixes, frontend), one of Pardes.views[4] (null when closed), the live one views[live] through Pardes.view() (index field `view` renamed `live`); going into another view is the index plus the panes' shares, which stay swapped (park and unpark now move only Pane.pv); views.zig loses fields, Part over Pardes, Parked, kept, emptied and the session half of every copy, and a pane closing leaves every view's layout at once (views.gone, at the two places a slot is freed) instead of the serials each parked view kept; drawOne and within put the drawn view's own share back whole; the views are in the digest now (tape's per-field parts name views[k].field), so a fresh view's col_x/col_w default to zeros, not undefined; the dump keeps every open view in the core and the panes' shares of the others under `shares`; an image from before (live view as the core's own fields, the rest under `views`) loads them into views[] once; the ~2,400 references rewritten mechanically from the compiler's errors (p.active is p.view().active, `const v = p.view()` hoisted in 823 places), Kind.zig (4 lines) and addon_test.zig (3) among them, macos.zig by pattern (not compiled here); tape's watched host writes read the live view's frontend and active; perf.zig's accessor lines change its harness hash, the debug baselines re-keyed to it (their numbers the base's); no golden changes; gates: core-test 956/956 both, unit-test 1487/1488 tui and 1530/1531 gui, behaviour-test 248/248 both, pane-test 171/172, snap all 105 ok, process-test 0 of 37 failed tui, replicas ok
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Messages.zig')
-rw-r--r--src/Messages.zig88
1 files changed, 44 insertions, 44 deletions
diff --git a/src/Messages.zig b/src/Messages.zig
index 66beb6bc..ad91cf8d 100644
--- a/src/Messages.zig
+++ b/src/Messages.zig
@@ -52,7 +52,7 @@ fn leaderText(p: *const Pardes, buf: *[16]u8) []const u8 {
buf.* = @splat(' ');
@memcpy(buf[0..3], "SPC");
var end: usize = 3;
- for (p.leader_keys[0..p.leader_n]) |ch| {
+ for (p.view().leader_keys[0..p.view().leader_n]) |ch| {
if (end + 2 > buf.len) break;
buf[end + 1] = ch;
end += 2;
@@ -522,7 +522,7 @@ fn collectBands(p: *Pardes, pane: *Pane, r: Rect, id: usize) void {
// new one lands under them; when rows run out the oldest go first.
for (pane.msg_older[0..pane.msg_older_len], 0..) |line, i| pane.notices.pushAt(.older, @intCast(i), line.slot);
if (pane.msg_len > 0) pane.notices.pushAt(.message, 0, pane.msg_slot);
- if (id == p.active and p.prefix == .leader) pane.notices.push(.leader);
+ if (id == p.view().active and p.view().prefix == .leader) pane.notices.push(.leader);
// Del's question shows once its delay is up: answered before that, it
// was never there.
const del_waiting = pane.prompt == .del_side and pane.question_due_ns > p.clock.now_ns;
@@ -576,7 +576,7 @@ test "the message log keeps what the row forgets, and collapses repeats" {
// The same text from a DIFFERENT pane is a different event: one pane's
// failure must not be recorded as another's.
p.newScratchBelow(0);
- const other = p.active;
+ const other = p.view().active;
setMessage(p, other, "save: AccessDenied");
try std.testing.expectEqual(@as(usize, 3), p.messages.len);
try std.testing.expectEqual(p.panes[other].?.serial, p.messages.at(2).?.serial);
@@ -643,9 +643,9 @@ test "Msg writes the transient row by hand, bare or with text, and input ends it
test "with no frontend attached a message goes once it has lingered, on the clock" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer p.deinit();
- const pane = p.panes[p.active].?;
- p.setMessage(p.active, "said");
- p.setMessage(p.active, "said again");
+ const pane = p.panes[p.view().active].?;
+ p.setMessage(p.view().active, "said");
+ p.setMessage(p.view().active, "said again");
// Attached: it waits for input, however long.
pane.msg_said_ms -= 60_000;
p.update(.tick);
@@ -661,7 +661,7 @@ test "with no frontend attached a message goes once it has lingered, on the cloc
try std.testing.expectEqual(@as(u16, 0), pane.msg_len);
try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len);
// A fresh one stays until its linger is up.
- p.setMessage(p.active, "fresh");
+ p.setMessage(p.view().active, "fresh");
p.update(.tick);
try std.testing.expect(pane.msg_len > 0);
}
@@ -670,15 +670,15 @@ test "a message lingers past the input that dismisses it, and goes" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
defer p.deinit();
while (p.nextEffect()) |_| {}
- const pane = p.panes[p.active].?;
- try std.testing.expect(p.executeBuiltinLine(p.active, "MessageLinger 160"));
- try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello"));
+ const pane = p.panes[p.view().active].?;
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "MessageLinger 160"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg hello"));
// Shown at once, until input; the same line again stays shown.
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
try std.testing.expect(!p.animationActive());
for (0..100) |_| p.update(.tick);
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
- try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg hello"));
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
// Input (a key that announces nothing): 160 ms of lingering (ten frames), unaffected by more input...
p.update(.{ .key = .{ .cp = 'h' } });
@@ -697,12 +697,12 @@ test "a message lingers past the input that dismisses it, and goes" {
try std.testing.expect(!p.animationActive());
// Shown again while lingering: fresh, so it stays; a status update to a
// line on screen swaps its text in place.
- try std.testing.expect(p.executeBuiltinLine(p.active, "Msg again"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg again"));
p.update(.{ .key = .{ .cp = 'h' } });
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase);
- try std.testing.expect(p.executeBuiltinLine(p.active, "Msg again"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg again"));
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
- setStatus(p, p.active, "progress 50%");
+ setStatus(p, p.view().active, "progress 50%");
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
try std.testing.expectEqualStrings("progress 50%", pane.msg[0..pane.msg_len]);
try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len);
@@ -712,20 +712,20 @@ test "messages stack, oldest on top, each on its own timing" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
defer p.deinit();
while (p.nextEffect()) |_| {}
- const pane = p.panes[p.active].?;
- try std.testing.expect(p.executeBuiltinLine(p.active, "Verbose off"));
- try std.testing.expect(p.executeBuiltinLine(p.active, "MessageLinger 160"));
+ const pane = p.panes[p.view().active].?;
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Verbose off"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "MessageLinger 160"));
// `Verbose off` announced itself before it took effect.
pane.msg_len = 0;
pane.msg_life = .{};
- setMessage(p, p.active, "first");
+ setMessage(p, p.view().active, "first");
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
// A second message stacks under the first instead of replacing it.
- setMessage(p, p.active, "second");
+ setMessage(p, p.view().active, "second");
try std.testing.expectEqual(@as(u8, 1), pane.msg_older_len);
try std.testing.expectEqualStrings("first", pane.msg_older[0].slice());
try std.testing.expectEqualStrings("second", pane.msg[0..pane.msg_len]);
- collectNotices(p, pane, p.rects[p.active], p.active);
+ collectNotices(p, pane, p.view().rects[p.view().active], p.view().active);
try std.testing.expectEqual(Pane.Notices.Kind.older, pane.notices.kinds[0]);
try std.testing.expectEqual(Pane.Notices.Kind.message, pane.notices.kinds[1]);
// One key dismisses both, each on its own clock: a line already
@@ -734,7 +734,7 @@ test "messages stack, oldest on top, each on its own timing" {
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_older[0].life.phase);
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase);
p.update(.tick);
- setMessage(p, p.active, "third");
+ setMessage(p, p.view().active, "third");
try std.testing.expectEqual(@as(u8, 2), pane.msg_older_len);
p.update(.{ .key = .{ .cp = 'h' } });
const linger = messageFrames(p.settings.message_linger_ms);
@@ -747,24 +747,24 @@ test "messages stack, oldest on top, each on its own timing" {
try std.testing.expectEqual(@as(u16, 0), pane.msg_len);
try std.testing.expect(!p.animationActive());
// A status ticking in place does not pile up.
- setStatus(p, p.active, "lsp 10%");
- setStatus(p, p.active, "lsp 20%");
+ setStatus(p, p.view().active, "lsp 10%");
+ setStatus(p, p.view().active, "lsp 20%");
try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len);
// Lines keep their rows: when the top one leaves, the one under it does
// not move up, and the next message fills the gap instead.
- setMessage(p, p.active, "top");
- setMessage(p, p.active, "under");
+ setMessage(p, p.view().active, "top");
+ setMessage(p, p.view().active, "under");
try std.testing.expectEqual(@as(u8, 0), pane.msg_older[0].slot);
try std.testing.expectEqual(@as(u8, 1), pane.msg_slot);
pane.removeOlderMessage(0);
- collectNotices(p, pane, p.rects[p.active], p.active);
+ collectNotices(p, pane, p.view().rects[p.view().active], p.view().active);
try std.testing.expectEqual(@as(u8, 1), pane.notices.row[0]);
try std.testing.expectEqual(@as(u8, 2), pane.notices.span());
- setMessage(p, p.active, "fills");
+ setMessage(p, p.view().active, "fills");
try std.testing.expectEqual(@as(u8, 0), pane.msg_slot);
try std.testing.expectEqual(@as(u8, 1), pane.msg_older[0].slot);
// The stack keeps the newest few.
- for ([_][]const u8{ "a", "b", "c", "d", "e" }) |text| setMessage(p, p.active, text);
+ for ([_][]const u8{ "a", "b", "c", "d", "e" }) |text| setMessage(p, p.view().active, text);
try std.testing.expectEqual(@as(u8, Pane.message_stack), pane.msg_older_len);
try std.testing.expectEqualStrings("b", pane.msg_older[0].slice());
try std.testing.expectEqualStrings("e", pane.msg[0..pane.msg_len]);
@@ -773,23 +773,23 @@ test "messages stack, oldest on top, each on its own timing" {
test "a builtin announces itself on the message row, and Verbose silences it" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
defer p.deinit();
- const pane = p.panes[p.active].?;
+ const pane = p.panes[p.view().active].?;
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.
- try std.testing.expect(p.executeBuiltinLine(p.active, "Wrap"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Wrap"));
try std.testing.expectEqualStrings("Wrap", pane.msg[0..pane.msg_len]);
// A value it does not take is said, in place of the announcement.
const wrapped = p.settings.wrap;
- try std.testing.expect(p.executeBuiltinLine(p.active, "Wrap maybe"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Wrap maybe"));
try std.testing.expectEqualStrings("Wrap: takes on, off", pane.msg[0..pane.msg_len]);
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.rects[p.active], p.active);
+ 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]);
@@ -798,7 +798,7 @@ test "a builtin announces itself on the message row, and Verbose silences it" {
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
_ = try p.render(frame.allocator());
- const r = p.rects[p.active];
+ 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;
@@ -812,32 +812,32 @@ test "a builtin announces itself on the message row, and Verbose silences it" {
try std.testing.expect(line[0].grapheme()[0] == ' ');
// Msg owns the row itself, so it does not announce over its own text.
- try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg hello"));
try std.testing.expectEqualStrings("hello", pane.msg[0..pane.msg_len]);
pane.msg_len = 0;
p.settings.verbose = false;
- try std.testing.expect(p.executeBuiltinLine(p.active, "Wrap"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Wrap"));
try std.testing.expectEqual(@as(u16, 0), pane.msg_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 });
defer p.deinit();
- const id = p.active;
+ 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.rects[id];
+ 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.prefix = .leader;
- p.leader_n = 0;
+ 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);
@@ -861,7 +861,7 @@ test "notices stack over the body's top rows without moving them" {
try std.testing.expect(pane.notices.left[0] < pane.notices.left[1]);
// Gone with the notices: no stale chip left behind.
- p.prefix = .none;
+ p.view().prefix = .none;
pane.msg_len = 0;
_ = frame.reset(.retain_capacity);
_ = try p.render(frame.allocator());
@@ -876,9 +876,9 @@ test "an idle core wants no wake and a lingering message sleeps to its linger's
const frame = pardes.frame_ns;
p.advance(1_000_000);
try std.testing.expectEqual(@as(?u64, null), p.nextWake());
- const pane = p.panes[p.active].?;
+ const pane = p.panes[p.view().active].?;
// Shown, a message asks for no wake.
- try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg hello"));
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
try std.testing.expectEqual(@as(?u64, null), p.nextWake());
// A key starts the 800 ms linger: the core sleeps to its end, not a
@@ -898,8 +898,8 @@ test "an idle core wants no wake and a lingering message sleeps to its linger's
// A long linger ends when it says, jumped in one step, not stretched by
// the cap on catching up with moving frames.
- try std.testing.expect(p.executeBuiltinLine(p.active, "MessageLinger 5000"));
- try std.testing.expect(p.executeBuiltinLine(p.active, "Msg again"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "MessageLinger 5000"));
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg again"));
p.update(.{ .key = .{ .cp = 'x' } });
const long_due = p.clock.stepped_ns + messageFrames(5000) * frame;
try std.testing.expectEqual(@as(?u64, long_due), p.nextWake());