summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 22:58:52 -0300
committerGabriel Schneider <[email protected]>2026-11-24 23:08:45 -0300
commitc9114545cce7f7598a4929d8254de1d3baccde84 (patch)
tree737fd78175bb97e414ce53b67ac6152cf4d74981
parent226d8a7635959644a2bafc3d621648c7a5aca2ad (diff)
downloadpardes-c9114545cce7f7598a4929d8254de1d3baccde84.tar.gz
pardes-c9114545cce7f7598a4929d8254de1d3baccde84.zip
TagState, tagline, Messages: a question waiting on a pane is its tag's head while the tag is at rest, in place of the tag's own words, not text in its prefix (walk UI G item 2b, ruling R1, SPEC §3.2's asking row and §10.2): C's asking text (Messages.askingText) was put after the path in tagline.prefixIn, so the tag's own words followed it (`… d Diff · SPC e to answer Save Term Collapse Follow Del`) and an edit's prefix check (edit.zig setEditTextSpan reads pathPrefix) took it for the own text; now TagState.head answers for a pane not out of rest in the view with `asking`: the question's words, `▸` and each answer's key in the key ink, its word, `· SPC e to answer` (`· Esc later` while SPC e has given it the keyboard) dimmed, computed and read-only as A's heads are (drawn with their spans, its edits refused), never written into tag.own, which is back when the question goes; a pane state (Messages.waiting), so every view shows it, and not while the tag has the keyboard (its own text is edited then) nor while the view's level or typing state is in it (the level's head wins); the mark `?` in the box's second cell is C's; askingText and prefixIn's concat go (a 512-byte buffer and a concat a tag a frame); TEST FIRST: Messages.zig 'a file changed on disk under unsaved text asks…' now reads the shown tag: it ends with the question and holds no Save, the prefix holds no question, the head is there (edits refused), SPC's key cell replaces it and Esc brings it back (on the parent the tag ends `… Follow Del`); GOLDEN filewatch: `kept` and `reloaded_sub` row 6 lose the tag's own words after the question, nothing else; tui core-test 1034/1203 (169 skipped), process-test 0 of 146 failed after that update (1 before it: filewatch)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--core/Messages.zig33
-rw-r--r--core/TagState.zig32
-rw-r--r--core/tagline.zig7
-rw-r--r--test/snapshots/filewatch.golden2
4 files changed, 49 insertions, 25 deletions
diff --git a/core/Messages.zig b/core/Messages.zig
index 8ecf2919..7cee0d25 100644
--- a/core/Messages.zig
+++ b/core/Messages.zig
@@ -485,19 +485,6 @@ pub fn waitingAnswers(m: *const Messages, pane: *const Pane) []const Answer {
return m.live[i].asks.answers();
}
-/// The waiting question's words as its pane's tag asks them, while the tag
-/// is at rest (SPEC §3.2 asking): what it asks, its answers, and how to
-/// give one. `answering`: SPC e gave it the keyboard.
-pub fn askingText(m: *const Messages, pane: *const Pane, answering: bool, out: []u8) []const u8 {
- const i = m.waiting(pane) orelse return "";
- const s = &m.live[i];
- var w: std.Io.Writer = .fixed(out);
- w.print("{s} \u{25b8}", .{s.words()}) catch {};
- for (s.asks.answers()) |a| w.print(" {c} {s} ", .{ a.key, a.word }) catch {};
- w.writeAll(if (answering) "\u{b7} Esc later" else "\u{b7} SPC e to answer") catch {};
- return w.buffered();
-}
-
/// Answer live question `i` with `key`: `r` reads the file again over its
/// unsaved text, `k` keeps the text and lets the disk's be, `d` shows (or
/// hides again) the disk's lines where they differ, as ghosts in its
@@ -1318,9 +1305,25 @@ test "a file changed on disk under unsaved text asks in its tag and never takes
p.update(.{ .file_changed = .{ .pane = .at(id), .bytes = disk } });
const i = p.messages.waiting(pane) orelse return error.NotAsked;
try std.testing.expectEqual(Kind.question, p.messages.live[i].kind);
- // In its tag at rest, its answers offered; its mark `?`.
+ // In its tag at rest, its answers offered in place of the tag's own
+ // words (the head, walk UI R1), read-only; its mark `?`.
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const shown = try pardes.tagline.tagText(p, frame.allocator(), pane);
+ try std.testing.expect(std.mem.endsWith(u8, shown, " changed on disk \u{25b8} r Reload k Keep mine d Diff \u{b7} SPC e to answer"));
+ try std.testing.expect(std.mem.startsWith(u8, shown, path));
+ try std.testing.expectEqual(Kind.question, p.messages.markOf(pane).?);
+ try std.testing.expect(std.mem.indexOf(u8, shown, "Save") == null);
const prefix = try pardes.tagline.tagPrefix(p, pane);
- try std.testing.expect(std.mem.indexOf(u8, prefix, "changed on disk \u{25b8} r Reload k Keep mine d Diff \u{b7} SPC e to answer") != null);
+ try std.testing.expect(std.mem.indexOf(u8, prefix, "changed on disk") == null);
+ // The tag's own text is no one's to edit meanwhile.
+ try std.testing.expect((try pardes.TagState.head(p, frame.allocator(), pane)) != null);
+ // Out of rest (SPC: its key cell at once) the level's head, not the
+ // question; at rest again, the question.
+ p.update(.{ .key = .{ .cp = ' ' } });
+ try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagText(p, frame.allocator(), pane), "changed on disk") == null);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagText(p, frame.allocator(), pane), "changed on disk") != null);
try std.testing.expectEqualStrings("Reload", p.messages.waitingAnswers(pane)[0].word);
// The keyboard is not its: `r` is the body's (helix's replace).
p.update(.{ .key = .{ .cp = 'k' } });
diff --git a/core/TagState.zig b/core/TagState.zig
index e4053f51..24d863bc 100644
--- a/core/TagState.zig
+++ b/core/TagState.zig
@@ -266,6 +266,32 @@ pub fn loaded(p: *Pardes) void {
};
}
+/// Asking (SPEC §3.2, §10.2): a question waiting on the pane, its tag at
+/// rest, in place of the tag's own text: what it asks, `▸`, each answer's
+/// key and word, and how to give one (`Esc later` while SPC e has given it
+/// the keyboard). The pane's state, not the view's keyboard: every view
+/// shows it; not while the tag has the keyboard, whose own text is edited
+/// then.
+fn asking(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head {
+ if (pane.focus == .tag or pane.prompt == .name) return null;
+ const i = p.messages.waiting(pane) orelse return null;
+ const said = &p.messages.live[i];
+ var b: Builder = .{ .arena = arena };
+ try b.put(" ");
+ try b.put(said.words());
+ try b.put(" ");
+ try b.styled("▸", .key);
+ for (said.asks.answers()) |a| {
+ try b.put(" ");
+ try b.styled(&.{a.key}, .key);
+ try b.put(" ");
+ try b.put(a.word);
+ try b.put(" ");
+ }
+ try b.styled(if (p.view().answering == pane.serial) "· Esc later" else "· SPC e to answer", .dim);
+ return b.done();
+}
+
/// The last leaf run in the current level, as the line under it says it
/// (Messages' leader band): `k Hover: its summary (last used here)`, while
/// the level is shown rolled.
@@ -441,10 +467,10 @@ const Builder = struct {
};
/// The head of pane `pane`'s tag while it is out of rest in the live view,
-/// null at rest.
+/// or while a question waits on it at rest (`asking`); null at rest.
pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head {
- const id = hostOf(p) orelse return null;
- if (p.panes[id] != pane) return null;
+ const id = hostOf(p) orelse return asking(p, arena, pane);
+ if (p.panes[id] != pane) return asking(p, arena, pane);
const v = p.view();
const s = &v.tag_state;
var b: Builder = .{ .arena = arena };
diff --git a/core/tagline.zig b/core/tagline.zig
index 9e9b9757..78d5a256 100644
--- a/core/tagline.zig
+++ b/core/tagline.zig
@@ -220,12 +220,7 @@ pub fn tagPrefix(p: *Pardes, pane: *Pane) ![]u8 {
/// The prefix as the tag shows it, built in `arena`.
pub fn prefixIn(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]u8 {
- const path = try pathPrefix(p, arena, pane);
- // Asking (SPEC §3.2): a question waiting on it, after the path while
- // the tag is at rest (not while it has the keyboard).
- var asking: [512]u8 = undefined;
- const asks = if (pane.focus == .tag or pane.prompt == .name) "" else p.messages.askingText(pane, p.view().answering == pane.serial, &asking);
- const prefix = if (asks.len > 0) try std.mem.concat(arena, u8, &.{ path, " ", asks }) else path;
+ const prefix = try pathPrefix(p, arena, pane);
// The space between the prefix and the tag's own text is the text's
// (every default starts with one), but the prefix is computed, so it
// cannot trust the text to keep it: with it deleted, Look and Exec
diff --git a/test/snapshots/filewatch.golden b/test/snapshots/filewatch.golden
index b9716691..dfac8cd6 100644
--- a/test/snapshots/filewatch.golden
+++ b/test/snapshots/filewatch.golden
@@ -31,7 +31,7 @@
|
| · @p1 a copy of the terminal's text: Tab or B2 runs it; what the program draws next replaces it (Ctrl-b types to the program) 1 message · SPC h m
== snap kept grid=210x31 cursor=15,7
-|6: ?/tmp/pardes-snap/filewatch/cwd/w.txt changed on disk ▸ r Reload k Keep mine d Diff · SPC e to answer Save Term Collapse Follow Del
+|6: ?/tmp/pardes-snap/filewatch/cwd/w.txt changed on disk ▸ r Reload k Keep mine d Diff · SPC e to answer
|30: ? /tmp/pardes-snap/filewatch/cwd/w.txt changed on disk 1 question · SPC e
== snap reloaded_sub grid=210x31 cursor=15,7
|19: 1 RENAMED