summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Core.zig5
-rw-r--r--core/mouse.zig44
2 files changed, 49 insertions, 0 deletions
diff --git a/core/Core.zig b/core/Core.zig
index b4745b24..360ba833 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -1594,6 +1594,10 @@ fn serveFsInner(p: *Pardes, req: ctlfs.Req) ctlfs.Reply {
pub const update = pardes.tape.taped(updateInner);
fn updateInner(p: *Pardes, ev: Event) void {
const v = p.view();
+ // Its bands as its state stands: a step reads them (a press on a chip, a
+ // body's top under them), and what a frame drew, a view put back or a
+ // dump left in Pane.notices (derived) is not what every core has.
+ for (p.panes, 0..) |slot, id| if (slot) |pane| Messages.collectNotices(p, pane, v.rects[id], id);
defer pardes.panes.File.syncTwins(p);
defer p.reportFocus();
// A tick with no deadline due is the one event that cannot change
@@ -1812,6 +1816,7 @@ fn noteLateFailureInner(p: *Pardes, id: usize) void {
pub const presented = pardes.tape.taped(presentedInner);
fn presentedInner(p: *Pardes) void {
const v = p.view();
+ for (p.panes, 0..) |slot, id| if (slot) |pane| Messages.collectNotices(p, pane, v.rects[id], id);
if (v.pointer_inside and v.drag != .none) {
v.hover_col = v.pointer_raw_col;
v.hover_row = v.pointer_raw_row;
diff --git a/core/mouse.zig b/core/mouse.zig
index 8e761453..150ea81c 100644
--- a/core/mouse.zig
+++ b/core/mouse.zig
@@ -1769,6 +1769,50 @@ test "a tag press is the same state whichever frame this process drew last" {
try expectSame(two.a, two.b, "after the press");
}
+// A notice band over a body's top rows is derived (Pane.notices): a frame
+// writes it at its own time, so a step makes it again as its state stands
+// before it reads it. Here the session draws a frame once Del's question is
+// due (its band shown) and the replica none: a press on the band's chip is
+// the same in both (the soak's divergence, through `kindMouse`, was this read).
+test "a press on a notice's chip is the same state whichever frame this process drew last" {
+ const gpa = std.testing.allocator;
+ const a = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 40 });
+ defer a.deinit();
+ a.update(.{ .resize = .{ .cols = 80, .rows = 40, .row_metrics = test_metrics } });
+ // Del asks which neighbour takes the rows of a pane with two.
+ a.newScratchBelow(a.view().active);
+ const mid = a.view().active;
+ a.newScratchBelow(mid);
+ a.view().active = mid;
+ a.sync();
+ const bytes = try pardes.dump.dumpBytes(a);
+ defer gpa.free(bytes);
+ const b = try pardes.dump.load(gpa, a.opts, bytes, null);
+ defer b.deinit();
+ for ([_]*Pardes{ a, b }) |p| {
+ p.clock.now_ns = 5 * std.time.ns_per_s;
+ p.clock.stepped_ns = p.clock.now_ns;
+ p.update(.{ .key = .{ .cp = ' ' } });
+ p.update(.{ .key = .{ .cp = 'd' } });
+ p.clock.now_ns = p.panes[mid].?.question_due_ns;
+ }
+ var frame: std.heap.ArenaAllocator = .init(gpa);
+ defer frame.deinit();
+ _ = try a.render(frame.allocator());
+ const pane = a.panes[mid].?;
+ try std.testing.expect(pane.notices.len > 0);
+ const last = pane.notices.len - 1;
+ try std.testing.expectEqual(Pane.Notices.Kind.prompt, pane.notices.kinds[last]);
+ const row = a.bodyTop(pane, a.view().rects[mid]) + pane.notices.row[last];
+ const press: pardes.Event = .{ .mouse = .{ .button = .left, .kind = .press, .col = pane.notices.left[last] + 1, .row = row } };
+ a.update(press);
+ b.update(press);
+ // What the press did (a pane's cwd and a message's wall-clock stamp
+ // differ between two cores in one test process: not compared).
+ try std.testing.expectEqual(a.view().drag, b.view().drag);
+ try std.testing.expectEqual(a.panes[mid].?.sel[0], b.panes[mid].?.sel[0]);
+}
+
// The same through a body hit (edit.pointerTextSelection, a sweep's drag),
// on a compact body layer (TreeContext), which a pixel shell inverts.
test "a body press, drag and release are the same state whichever frame this process drew last" {