summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 21:27:16 -0300
committerGabriel Schneider <[email protected]>2026-11-24 21:28:51 -0300
commit2e29f8ffebda59aa528c392535b7f1db31be91f8 (patch)
treebadd7ae81363eb86fb366619952fd6658415b5a0 /core
parente91261ff4f4602afec14d2fb958fd3e51a4dc62d (diff)
downloadpardes-2e29f8ffebda59aa528c392535b7f1db31be91f8.tar.gz
pardes-2e29f8ffebda59aa528c392535b7f1db31be91f8.zip
messages: SPC e acts on the message the notice row leads with, SPC h m is the history newest first, and Esc at rest takes a thing at a time (pick-ui SPEC §10.4, walk UI line C item 5): the Message word (SPC e, quiet: what it does shows) lists an error's places in a +Search under the pane and lands on the first (today's list, walked by the Look walk until agent D's picker lands lists in the pane), the error gone; a question gets the keyboard in its tag (View.answering, item 4); anything else, or nothing, opens the history; the history (Messages, SPC h m) is the log ring newest first, each line its kind's glyph, a live error's places under it, a question's answer logged after it; Esc in normal mode at rest takes a search's tints first (Places.clear), then the warnings and errors, then the extra selections (the primary kept), and only then goes back to the previous pane; tests: Messages.zig 'SPC e on an error that names places lists them under the pane and lands on the first, on a question gives its tag the keyboard, and on anything else opens the history, the newest first', 'Esc at rest takes a search's tints first, then the warnings and errors, and only then goes back'; docs/typ/builtins-tui.json from the registry; tui: core-test, shell-test, pane-test, behaviour-test pass; process-test 0 of 146 failed after the builtins and leader goldens took the Messages word's longer doc line
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core')
-rw-r--r--core/Messages.zig92
-rw-r--r--core/Output.zig18
-rw-r--r--core/builtins.zig17
-rw-r--r--core/config.zig1
-rw-r--r--core/normal.zig13
5 files changed, 134 insertions, 7 deletions
diff --git a/core/Messages.zig b/core/Messages.zig
index e421a32c..a26cbad9 100644
--- a/core/Messages.zig
+++ b/core/Messages.zig
@@ -547,6 +547,38 @@ pub fn answer(p: *Pardes, i: usize, key: u8) bool {
return true;
}
+/// SPC e (the Message word, SPEC §10.4), on the message the notice row
+/// leads with: an error that names places lists them in a +Search under
+/// pane `id`, where n and N walk them, the first landed on, and the error
+/// goes; a question takes the keyboard in its pane's tag; anything else,
+/// or nothing, opens the history.
+pub fn act(p: *Pardes, id: usize) void {
+ const m = &p.messages;
+ const lead = m.headline() orelse return openHistory(p, id);
+ if (lead.kind == .question) {
+ p.view().answering = lead.pane;
+ p.needs_frame = true;
+ return;
+ }
+ if (lead.kind != .@"error" or lead.places_len == 0 or id >= MAX_PANES) return openHistory(p, id);
+ const pane = p.panes[id] orelse return;
+ var rows: std.Io.Writer.Allocating = .init(p.gpa);
+ errdefer rows.deinit();
+ for (lead.places[0..lead.places_len]) |*place| rows.writer.print("{s}:{d}:{d} {s}\n", .{ place.path.slice(), place.line, place.col, place.text.slice() }) catch |err| return reportError(p, .at(id), "Message", err);
+ const cause = lead.src;
+ const lead_at = for (m.live[0..m.live_len], 0..) |*s, k| {
+ if (s == lead) break k;
+ } else return;
+ m.remove(lead_at);
+ const content = rows.toOwnedSlice() catch |err| return reportError(p, .at(id), "Message", err);
+ pardes.panes.Output.fillResults(p, id, pardes.panes.paneDir(pane), .search, cause.slice(), content, null) catch |err| return reportError(p, .at(id), "Message", err);
+ _ = @import("look.zig").searchStep(p, id, 1);
+}
+
+fn openHistory(p: *Pardes, id: usize) void {
+ pardes.panes.Output.openMessages(p, id) catch |err| reportError(p, .at(id), "messages", err);
+}
+
/// An Exec of an answer's word in the tag of a pane a question waits on
/// (B2 on `Reload`): that answer. False for any other word.
pub fn answerWord(p: *Pardes, id: usize, word: []const u8) bool {
@@ -1285,3 +1317,63 @@ test "a file changed on disk under unsaved text asks in its tag and never takes
try std.testing.expect(p.messages.waiting(pane) == null);
try std.testing.expectEqualStrings(disk, p.panes[id].?.file.?.content);
}
+
+test "SPC e on an error that names places lists them under the pane and lands on the first, on a question gives its tag the keyboard, and on anything else opens the history, the newest first" {
+ const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 });
+ defer p.deinit();
+ const pane = try p.setTestFile("one\ntwo\nthree\nfour\nfive\n");
+ const serial = pane.serial;
+ p.messages.live_len = 0;
+ const err = keep(p, .@"error", 0, "@p9 zig build", "exit 1");
+ for ([_]u32{ 2, 4 }, 0..) |line, k| {
+ err.places[k] = .{ .line = line, .col = 1 };
+ err.places[k].path.set("/test.txt");
+ err.places[k].text.set("bad");
+ }
+ err.places_len = 2;
+ p.update(.{ .key = .{ .cp = ' ' } });
+ p.update(.{ .key = .{ .cp = 'e' } });
+ while (p.nextEffect()) |_| {}
+ try std.testing.expect(p.messages.headline() == null);
+ const here = p.paneBySerial(serial).?;
+ const list = p.panes[p.panes[here].?.search_pane orelse return error.NoList].?;
+ try std.testing.expect(std.mem.indexOf(u8, list.file.?.content, "/test.txt:4:1") != null);
+ try std.testing.expectEqual(@as(i32, 1), p.panes[here].?.body.cur_row);
+ // A question: its tag gets the keyboard.
+ keep(p, .question, serial, "/test.txt", "changed on disk").asks = .disk;
+ try std.testing.expect(p.executeBuiltinLine(here, "Message"));
+ try std.testing.expectEqual(serial, p.view().answering);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(@as(u32, 0), p.view().answering);
+ // Anything else: the history, the newest first, each with its glyph.
+ p.messages.live_len = 0;
+ _ = say(p, .notice, here, "older words");
+ _ = say(p, .warn, here, "newer words");
+ try std.testing.expect(p.executeBuiltinLine(here, "Message"));
+ const history = for (p.panes) |slot| {
+ const shown = slot orelse continue;
+ const f = shown.file orelse continue;
+ if (std.mem.endsWith(u8, f.path, config.messages_buffer)) break f.content;
+ } else return error.NoHistory;
+ const newer = std.mem.indexOf(u8, history, "! ") orelse return error.NoGlyph;
+ try std.testing.expect(newer < std.mem.indexOf(u8, history, "older words").?);
+}
+
+test "Esc at rest takes a search's tints first, then the warnings and errors, and only then goes back" {
+ const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 });
+ defer p.deinit();
+ const pane = try p.setTestFile("alpha beta alpha\n");
+ const id = p.view().active;
+ p.messages.live_len = 0;
+ p.update(.{ .key = .{ .cp = '*' } });
+ p.update(.{ .key = .{ .cp = 'n' } });
+ while (p.nextEffect()) |_| {}
+ if (pane.places.pattern.len == 0 and pane.places.hits.items.len == 0) return error.NoTints;
+ _ = say(p, .@"error", id, "broke");
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expect(pane.places.pattern.len == 0 and pane.places.hits.items.len == 0);
+ try std.testing.expectEqual(@as(u8, 1), p.messages.live_len);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(@as(u8, 0), p.messages.live_len);
+ try std.testing.expectEqual(id, p.view().active);
+}
diff --git a/core/Output.zig b/core/Output.zig
index 380fadb1..a7398ccf 100644
--- a/core/Output.zig
+++ b/core/Output.zig
@@ -979,19 +979,27 @@ pub fn openConfig(p: *Pardes, id: usize) !void {
return openRead(p, id, .{ .cmd = .DumpConfig }, "", content);
}
-/// The message-row log, oldest first — the lines that were said in passing and
-/// then cleared by the next keystroke.
+/// The messages' history (the log ring), the newest first, each with its
+/// kind's glyph, a live error's places under it (SPC h m).
pub fn openMessages(p: *Pardes, id: usize) !void {
var out: std.Io.Writer.Allocating = .init(p.gpa);
errdefer out.deinit();
- var i: usize = 0;
- while (p.messages.at(i)) |m| : (i += 1) {
+ var i: usize = p.messages.len;
+ while (i > 0) {
+ i -= 1;
+ const m = p.messages.at(i).?;
+ try out.writer.print("{s} ", .{m.kind.glyph()});
if (m.serial != 0) try out.writer.print("{d}: ", .{m.serial});
try out.writer.writeAll(m.slice());
if (m.repeats > 1) try out.writer.print(" (x{d})", .{m.repeats});
try out.writer.writeByte('\n');
+ for (p.messages.live[0..p.messages.live_len]) |*s| {
+ if (s.kind != .@"error" or s.places_len == 0 or !std.mem.eql(u8, pardes.Messages.Message.body(s.text.slice()), pardes.Messages.Message.body(m.slice()))) continue;
+ for (s.places[0..s.places_len]) |*place| try out.writer.print(" {s}:{d}:{d} {s}\n", .{ place.path.slice(), place.line, place.col, place.text.slice() });
+ break;
+ }
}
- if (i == 0) try out.writer.writeAll("nothing has been said yet\n");
+ if (p.messages.len == 0) try out.writer.writeAll("nothing has been said yet\n");
const content = try out.toOwnedSlice();
return openRead(p, id, .{ .cmd = .Messages }, "", content);
}
diff --git a/core/builtins.zig b/core/builtins.zig
index 0c643a18..af53fa6f 100644
--- a/core/builtins.zig
+++ b/core/builtins.zig
@@ -1709,7 +1709,22 @@ pub const LocationsConfig = struct {
}
};
-/// Show the messages said so far in a +Messages.
+/// Act on the message the notice row leads with.
+///
+/// An error that names places lists them in a +Search, which the Look walk
+/// steps through; a question takes the keyboard in its pane's tag (its
+/// answer's key answers it, Esc leaves it waiting); anything else opens the
+/// history.
+pub const Message = struct {
+ pub const quiet = true;
+ pub const scope: Scope = .session;
+ pub fn run(c: Ctx) void {
+ pardes.Messages.act(c.p, c.id);
+ }
+};
+
+/// Show the messages said so far in a +Messages, the newest first, an
+/// error's places under it.
pub const Messages = struct {
pub const scope: Scope = .session;
pub const output: OutputTraits = .{ .name = config.messages_buffer };
diff --git a/core/config.zig b/core/config.zig
index 9673da73..dd8ad5d3 100644
--- a/core/config.zig
+++ b/core/config.zig
@@ -115,6 +115,7 @@ pub const leader_path = paths: {
.Changelog = "hc",
.Build = "hb",
.Messages = "hm",
+ .Message = "e",
.Newcol = "cn",
.Delcol = "cd",
.Joincol = "cj",
diff --git a/core/normal.zig b/core/normal.zig
index 7efe0bf6..3dade7a6 100644
--- a/core/normal.zig
+++ b/core/normal.zig
@@ -1094,8 +1094,19 @@ pub fn textAction(e: Editor, t: *Text, a: modal.Normal.Action) edit.Error!void {
if (comptime Editor.lib) return;
// typed again by a macro, Esc is only helix's
if (e.p.macro.replaying > 0) return;
- // The warnings and errors first, then the previous pane.
+ // At rest a thing at a time (pick-ui SPEC §10.4): a search's
+ // tints, then the warnings and errors, then the selections
+ // (the primary kept); with none of them left, the previous pane.
+ if (e.p.panes[e.p.view().active]) |pane| if (t == &pane.body and (pane.places.pattern.len > 0 or pane.places.hits.items.len > 0)) {
+ pane.places.clear(e.p.gpa);
+ e.p.needs_frame = true;
+ return;
+ };
if (e.p.messages.retire(&.{ .warn, .@"error" }) > 0) return;
+ if (t.nsel > 0) {
+ t.nsel = 0;
+ return;
+ }
tagline.exitHeader(e.p); // out of a header too, as Shift-Esc
return exec.runBuiltin(e.p, .Last, e.p.view().active, "", null);
},