summaryrefslogtreecommitdiff
path: root/src/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/replica.zig')
-rw-r--r--src/replica.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/replica.zig b/src/replica.zig
index 0b55a5bf..032e50af 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -467,6 +467,9 @@ pub const Replica = struct {
/// Its terminals' screen state, as the authority's deltas made it.
screens: [pardes.MAX_PANES]?ScreenOf = @splat(null),
screen_out: std.ArrayListUnmanaged(u8) = .empty,
+ /// Its predicted echo (src/echo.zig), drawn over its core's terminals:
+ /// fed by its keys, its units and its deltas here, and by `echoFrame`.
+ echo: pardes.echo.Echo = .{},
const ScreenOf = struct {
serial: u32,
@@ -490,6 +493,7 @@ pub const Replica = struct {
r.deinit();
return error.NoCore;
}
+ if (screens) r.core().echo = &r.echo;
return r;
}
@@ -538,6 +542,7 @@ pub const Replica = struct {
try r.pending.append(r.gpa, .{ .seq = seq, .msg = msg });
r.dirty = true;
r.settle();
+ if (r.t.screen_state and r.diverged == null) r.echo.typed(r.core(), r.view, ev, seq, r.applied == r.pending.items.len);
r.out.clearRetainingCapacity();
try r.out.appendSlice(r.gpa, msg);
return r.out.items;
@@ -548,6 +553,7 @@ pub const Replica = struct {
if (r.diverged != null) return;
const u = parseUnit(msg) orelse return r.fail("a unit too short to read");
r.stats.units += 1;
+ if (u.origin == r.id) if (r.t.core) |c| r.echo.confirmed(c, u.seq);
const was = Stepping.begin(&r.t, &r.epoch);
defer was.end();
if (u.origin == r.id and r.pending.items.len > 0 and r.pending.items[0].seq == u.seq and r.applied > 0 and
@@ -716,6 +722,15 @@ pub const Replica = struct {
return true;
}
+ /// Its client's, once a frame before it draws: a predicted echo the
+ /// screen has not shown in time goes, and keys deferred behind one not
+ /// predicted are predicted once its doing is on the screen. Whether what
+ /// the overlay draws changed since the last call (by a key, a unit, a
+ /// delta or this: `echo.changed`).
+ pub fn echoFrame(r: *Replica) bool {
+ return r.echo.frame(r.core());
+ }
+
/// Nothing pending and nothing applied: the replica is the authority's
/// confirmed state, which `digest` says.
pub fn quiet(r: *const Replica) bool {
@@ -754,6 +769,7 @@ pub const Replica = struct {
r.stats.apply_ns.append(r.gpa, nowNs() - t0) catch {};
sc.refused = false;
terminal.takeMarks(state, applied.extra);
+ r.echo.delta(c, m.pane, sc.rep.top);
// Its rows as the core keeps them read are another grid's.
c.shell_rows.markStale(pane);
var seq: [4]u8 = undefined;