diff options
Diffstat (limited to 'core/echo.zig')
| -rw-r--r-- | core/echo.zig | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/core/echo.zig b/core/echo.zig index f35c9f9d..95127f55 100644 --- a/core/echo.zig +++ b/core/echo.zig @@ -1,7 +1,7 @@ //! Predicted echo for a replica's terminal panes, mosh's way //! (docs/next-daemon.md, "Phase 6: predicted echo notes"). A key typed into -//! a terminal goes to the authority, and its echo comes back as screen state -//! a round trip later: this shows it at once. +//! a terminal goes to the authority, and its echo comes back in the pty's +//! bytes a round trip later: this shows it at once. //! //! Presentation only. The overlay is the replica's own (`Pardes.echo`, a //! `.local` field the rollback copy skips), painted over a terminal's body @@ -368,6 +368,17 @@ pub const Echo = struct { e.catchUp(c); } + /// The pty's bytes road: the emulators were fed a unit's output (the + /// session's echo among it, perhaps): judged as at a delta, the active + /// area's first row its grid's. ponytail: at the history's cap that + /// row stops moving as the output scrolls; a guess there is judged + /// wrong and taken back, never kept. + pub fn fed(e: *Echo, c: *Pardes) void { + const pane = c.panes[e.pane] orelse return; + const g = Term.grid(pane.terminal orelse return); + e.delta(c, e.pane, g.total - g.len); + } + /// Once a frame: what is stale judged. Whether to draw. pub fn frame(e: *Echo, c: *Pardes) bool { if (e.n > 0 or e.cursor != null) e.judge(c, stale_ns); @@ -557,8 +568,6 @@ const replica = @import("replica.zig"); const Rig = struct { a: *replica.Authority, r: *replica.Replica, - screens: replica.Screens, - peer: u16, shell: u8, /// What the authority wrote its shell's pty. written: std.ArrayListUnmanaged(u8) = .empty, @@ -577,10 +586,11 @@ const Rig = struct { const gpa = testing.allocator; g.written = .empty; g.now = 1_000 * ms; - g.a = try replica.Authority.init(gpa, .{ .cols = 60, .rows = 16, .boot = .tty_shell }, .{ .ctx = g, .vtable = &vtable }, true); - g.screens = .init(gpa); - g.peer = try g.screens.addPeer(); - g.r = try replica.Replica.init(gpa, 1, try g.a.unit(0, 0), true); + // The one road: the shell's bytes in the units, fed to the + // replica's own emulator. + g.a = try replica.Authority.init(gpa, .{ .cols = 60, .rows = 16, .boot = .tty_shell }, .{ .ctx = g, .vtable = &vtable }, false); + g.r = try replica.Replica.init(gpa, 1, try g.a.unit(0, 0), false); + g.r.core().echo = &g.r.echo; g.shell = for (g.a.core.panes, 0..) |slot, id| { if (slot) |pane| if (pane.isTerminal()) break @intCast(id); } else return error.NoShell; @@ -589,7 +599,6 @@ const Rig = struct { fn deinit(g: *Rig) void { g.r.deinit(); - g.screens.deinit(g.a.core); g.a.deinit(); g.written.deinit(testing.allocator); } @@ -599,25 +608,15 @@ const Rig = struct { g.r.echo.now = g.now; } - /// The shell prints `bytes`; the replica gets the unit and the delta. + /// The shell prints `bytes`; the replica gets the unit. fn prints(g: *Rig, bytes: []const u8) !void { g.a.output(.{ .output = .{ .pane = .at(g.shell), .bytes = bytes } }); try g.sync(); } fn sync(g: *Rig) !void { - const gpa = testing.allocator; if (try g.a.pending()) |u| g.r.confirm(u); g.r.settle(); - var msgs: std.ArrayListUnmanaged([]u8) = .empty; - defer { - for (msgs.items) |m| gpa.free(m); - msgs.deinit(gpa); - } - try g.screens.flush(g.a.core, g.peer, &msgs); - for (msgs.items) |m| if (g.r.screen(m)) |reply| { - _ = try g.screens.take(g.a.core, g.peer, reply); - }; } /// The replica's client types `k`; the message for the authority. |
