diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 01:48:39 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:15 -0300 |
| commit | 5b5896965758ff8f2077c8e8e2f0250f580967c3 (patch) | |
| tree | 5dbd0a6d5be2d710395d14c42a686cb10d78e504 /src | |
| parent | eeac8cdf456148f02546f69dc197c6e9dca7876d (diff) | |
| download | pardes-5b5896965758ff8f2077c8e8e2f0250f580967c3.tar.gz pardes-5b5896965758ff8f2077c8e8e2f0250f580967c3.zip | |
Every answer to a pane's question is logged, answer - included
The log said ask but never what came of it, so a follower could not tell a
question taken back from one still standing. answerQuestion now records
answer <serial> <choice|-> whichever route answered, key or ctl; a key the
question does not offer is -. (Docs are in the tagexec change.)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/pardes.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 54fe2df0..706e9ef3 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -1712,6 +1712,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe const answered = th.wr(p, ctlfs.Node.of(file.serial, .ctl), "answer a\n"); try std.testing.expectEqual(ctlfs.Status.ok, answered.reply.status); try std.testing.expectEqualStrings("print(5)\r", answered.pty()); + try std.testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "answer {d} a\n", .{file.serial}))); } _ = exec.executeFrom(p, 0, "print(3)", true); p.update(.{ .key = .{ .cp = Key.escape } }); @@ -5573,8 +5574,17 @@ pub const Pardes = struct { } } + /// Answers the pane's question: a choice it offers, else (null, or a + /// key it does not offer) takes it back. The log says which, as + /// `answer <serial> <choice|->`, after the `ask` it answers. pub fn answerQuestion(p: *Pardes, id: usize, choice: ?u8) bool { const asked = p.panes[id] orelse return false; + var offered: [64]u8 = undefined; + if (p.questionChoices(id, &offered)) |choices| { + const chosen: ?u8 = if (choice) |c| (if (std.mem.indexOfScalar(u8, choices, c) != null and c != ' ') c else null) else null; + var rec: [32]u8 = undefined; + ctlfs.events.notePath(p, "answer", std.fmt.bufPrint(&rec, "{d} {c}", .{ asked.serial, chosen orelse '-' }) catch ""); + } switch (asked.prompt) { .repl_choice => { asked.prompt = .none; @@ -7085,10 +7095,12 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { try std.testing.expectEqual(Pane.Prompt.del_side, p.panes[asked].?.prompt); try std.testing.expectEqual(ctlfs.Status.ok, th.wr(p, ctl, "answer -\n").reply.status); try std.testing.expect(p.panes[asked] != null and p.panes[asked].?.prompt == .none); + try std.testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "answer {d} -\n", .{serial}))); p.update(.{ .key = .{ .cp = ' ' } }); p.update(.{ .key = .{ .cp = 'd' } }); try std.testing.expectEqual(ctlfs.Status.ok, th.wr(p, ctl, "answer k\n").reply.status); try std.testing.expect(p.paneBySerial(serial) == null); + try std.testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "answer {d} k\n", .{serial}))); } // Bare Del from anything but a key closes at once and gives the rows up, |
