summaryrefslogtreecommitdiff
path: root/core/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 18:52:44 -0300
committerGabriel Schneider <[email protected]>2026-11-24 19:00:51 -0300
commitf26cf0be705280ff28ca69aaef6cc64e1466ed4e (patch)
tree73fa0cb9bb356644c516c38fd6e72724c4c5e234 /core/panes.zig
parente9f3712ce17f9813ecb15dbf76d46778a49c747d (diff)
downloadpardes-f26cf0be705280ff28ca69aaef6cc64e1466ed4e.tar.gz
pardes-f26cf0be705280ff28ca69aaef6cc64e1466ed4e.zip
messages: one session-wide list of live messages replaces each pane's stack of chips (pick-ui SPEC §10.1, walk UI line C item 1): Messages.Said is a kind (echo, notice, warn, error, question, progress), its cause first as a word a Look understands (a file's path, @pN and its command), its text, the places it names and the lines that explain it, the pane it is about, the question it asks, ×n and the core's clock, in a fixed list of 16 (Messages.live); a new message retires every echo and notice, a new error the error before it, the same message right after itself is counted, progress from the same cause runs in place and is never the notice row's; an echo or a notice dims after MessageLinger (now 4000 ms, a warning twice as long: test configs' MessageLinger 0 keep their meaning, nothing dims and nothing wakes), and the core sleeps to that dim (Messages.dimDue in nextWake) instead of a frame-counted linger; no key or click dismisses a message any more: Esc in normal mode takes the warnings and errors first, then goes back as before; every call site says what it said, mapped by its entry: setMessage a notice, setStatus progress, reportError and reportFailure an error, a builtin's announcement an echo (exec.zig), the sent-to-a-REPL arrow an echo; the log ring stays the history and 9P /log (each line now with its kind); gone: Pane.msg, msg_older and their lives, slots, announcement, status and sent flags, dismissMessage, advanceMessages, holdMessages, messageWake, expireUnattended and the detached shells' 100 ms message waits; until the notice row (item 2) a pane's one message chip shows the newest message said of it (Messages.saidBy); an Upgrade's outcome is said once and is every view's; tests: Messages.zig 'an echo or a notice retires those before it, an error the error before it, a repeat counts and progress runs in place', 'Msg says a notice by hand ... and the next message retires it', 'an idle core wants no wake, and a message wakes it once, when it dims', runtime/upgrade.zig 'an upgrade's outcome stays on every view's notice row until something else is said'; core-test 862 pass 162 skip, pane-test and shell-test pass; behaviour-test: the pdf addon's script golden and one PDF Restore test move with the chip over a PDF's body, which item 2 takes away
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/panes.zig')
-rw-r--r--core/panes.zig98
1 files changed, 10 insertions, 88 deletions
diff --git a/core/panes.zig b/core/panes.zig
index 8939bd05..146b1360 100644
--- a/core/panes.zig
+++ b/core/panes.zig
@@ -32,7 +32,7 @@ pub const Pane = struct {
pub const replica = .{
.local = .{ "pv", "pv_known" },
.derived = .{ "wrap_line", "wrap_col", "wrap_pad", "wrap_n", "body_wrapped", "context_rows", "body_rows", "body_visible_rows", "context_row_limit", "geometry_key", "geometry_len", "top_skip", "notices", "pan" },
- .len = .{ .{ "msg", "msg_len" }, .{ "msg_older", "msg_older_len" }, .{ "question", "question_len" }, .{ "shell_tail", "shell_tail_len" }, .{ "sel_snap", "nsel_snap" } },
+ .len = .{ .{ "question", "question_len" }, .{ "shell_tail", "shell_tail_len" }, .{ "sel_snap", "nsel_snap" } },
// A picture's memory is its own allocator's (a dump loaded makes
// it there).
.alloc = .{ .{ "addon", "image" }, .{ "pdf", "image" }, .{ "terminal", "terminal" } },
@@ -242,8 +242,6 @@ pub const Pane = struct {
/// A question with its answers in it (`repl_choice`).
question: [96]u8 = undefined,
question_len: u8 = 0,
- /// The newest message says where an exec was sent: it is tinted.
- msg_sent: bool = false,
/// The revision an Exit or a Restore last warned this pane was modified
/// at, and which of them: only that word goes ahead on the warning
/// (builtins.zig warnModified).
@@ -347,27 +345,9 @@ pub const Pane = struct {
/// terminals only: the typed-text buffer standing in for shell rows
ovl: ?Text.EditBuffer = null,
tty_filter: bool = false,
- msg: [256]u8 = undefined,
- msg_len: u16 = 0,
- /// Where the newest message line is in its life.
- msg_life: MessageLife = .{},
- /// When it was said, in monotonic ms (Messages.expireUnattended).
- msg_said_ms: i64 = 0,
- /// The row (among the notice rows) the newest line holds for its life.
- msg_slot: u8 = 0,
- /// Earlier message lines still on screen, oldest first, each running its
- /// own life: a new message stacks under them instead of replacing them.
- msg_older: [message_stack]OlderMessage = undefined,
- msg_older_len: u8 = 0,
- /// The newest line is a builtin announcing itself in this step: what
- /// the step says next replaces it rather than stacking under it.
- msg_announcement: bool = false,
- /// The newest line is a status (progress, a server's state): the next
- /// line replaces it rather than stacking under it.
- msg_status: bool = false,
/// The transient lines this pane shows between its body and its tagline:
- /// a builtin's message, the pending leader chord, a prompt waiting for
- /// input. Rebuilt every frame from the state that owns each one, so a
+ /// 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
/// 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
@@ -398,67 +378,14 @@ pub const Pane = struct {
/// that view's focus leaving the pane drops it.
prompt_view: u8 = 0,
- pub const MessagePhase = enum { shown, lingering };
- /// One message line's life: shown, or lingering after the key or click
- /// that dismissed it, `frame` frames of its linger gone.
- pub const MessageLife = struct {
- phase: MessagePhase = .shown,
- frame: u16 = 0,
- };
- /// Older message lines kept on screen under a new one.
- pub const message_stack = 3;
- pub const OlderMessage = struct {
- pub const replica = .{ .len = .{.{ "text", "len" }} };
- text: [256]u8 = undefined,
- len: u16 = 0,
- life: MessageLife = .{},
- slot: u8 = 0,
-
- pub fn slice(line: *const OlderMessage) []const u8 {
- return line.text[0..line.len];
- }
- };
-
- /// Move the newest line onto the stack of older ones, dropping the oldest
- /// when it is full; the newest slot is left empty for what arrives.
- pub fn pushOlderMessage(pane: *Pane) void {
- if (pane.msg_older_len == message_stack) {
- std.mem.copyForwards(OlderMessage, pane.msg_older[0 .. message_stack - 1], pane.msg_older[1..]);
- pane.msg_older_len -= 1;
- }
- pane.msg_older[pane.msg_older_len] = .{ .text = pane.msg, .len = pane.msg_len, .life = pane.msg_life, .slot = pane.msg_slot };
- pane.msg_older_len += 1;
- pane.msg_len = 0;
- pane.msg_life = .{};
- }
-
- /// The first row no older line holds. A line keeps its row until it
- /// leaves, and a new one fills the first gap: nothing on screen moves.
- pub fn freeMessageSlot(pane: *const Pane) u8 {
- var used: u8 = 0;
- for (pane.msg_older[0..pane.msg_older_len]) |line| used |= @as(u8, 1) << @intCast(line.slot);
- var slot: u8 = 0;
- while (used & (@as(u8, 1) << @intCast(slot)) != 0) slot += 1;
- return slot;
- }
-
- pub fn removeOlderMessage(pane: *Pane, i: usize) void {
- std.mem.copyForwards(OlderMessage, pane.msg_older[i .. pane.msg_older_len - 1], pane.msg_older[i + 1 .. pane.msg_older_len]);
- pane.msg_older_len -= 1;
- }
-
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.
- /// `older` is an earlier message line still on screen; `index` says
- /// which (`Pane.msg_older`).
- pub const Kind = enum { older, message, leader, prompt };
- pub const max = @typeInfo(Kind).@"enum".field_names.len - 1 + message_stack;
+ pub const Kind = enum { message, leader, prompt };
+ pub const max = @typeInfo(Kind).@"enum".field_names.len;
kinds: [max]Kind = undefined,
- index: [max]u8 = @splat(0),
- /// Each band's row below the body's top: message lines keep theirs,
- /// so a band that leaves leaves a gap rather than moving the rest.
+ /// Each band's row below the body's top.
row: [max]u8 = @splat(0),
/// Where each band's chip starts, as an absolute grid column. A chip
/// is only as wide as its own text, so the rest of the row underneath
@@ -468,14 +395,9 @@ pub const Pane = struct {
/// A band on the next row after every band so far.
pub fn push(n: *Notices, kind: Kind) void {
- n.pushAt(kind, 0, n.span());
- }
-
- pub fn pushAt(n: *Notices, kind: Kind, index: u8, row: u8) void {
if (n.len >= max) return;
n.kinds[n.len] = kind;
- n.index[n.len] = index;
- n.row[n.len] = row;
+ n.row[n.len] = n.span();
n.left[n.len] = std.math.maxInt(u16);
n.len += 1;
}
@@ -1669,14 +1591,14 @@ test "owned cwd preserves long paths aliases and failed updates" {
const effects = p.effects_len;
exec.saveTo(p, 0, "file.txt");
try std.testing.expectEqual(effects, p.effects_len);
- try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "path too long") != null);
+ try std.testing.expect(std.mem.indexOf(u8, p.messages.saidBy(pane), "path too long") != null);
const current = pane.cwdSlice();
allocator.fail_index = allocator.alloc_index;
p.setCwd(.at(0), "/replacement");
try std.testing.expectEqual(current.ptr, pane.cwdSlice().ptr);
try std.testing.expectEqualStrings(&path, pane.cwdSlice());
- try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "out of memory") != null);
+ try std.testing.expect(std.mem.indexOf(u8, p.messages.saidBy(pane), "out of memory") != null);
allocator.fail_index = std.math.maxInt(usize);
p.setCwd(.at(0), "/replacement");
try std.testing.expectEqualStrings("/replacement", pane.cwdSlice());
@@ -1781,7 +1703,7 @@ test "owned cwd EOF failure retains the pane and Del retries its close" {
try std.testing.expectEqual(parent, p.panes[0].?);
try std.testing.expectEqual(parent, child.cwd.inherited);
try std.testing.expectEqual(Text.Mode.normal, parent.body.mode);
- try std.testing.expect(std.mem.indexOf(u8, parent.msg[0..parent.msg_len], "Del retries close") != null);
+ try std.testing.expect(std.mem.indexOf(u8, p.messages.saidBy(parent), "Del retries close") != null);
try std.testing.expectEqual(@as(usize, 0), p.effects_len);
allocator.fail_index = std.math.maxInt(usize);
try std.testing.expect(p.executeBuiltinLine(0, "Del"));