diff options
| -rw-r--r-- | src/pardes.zig | 2 | ||||
| -rw-r--r-- | src/replica.zig | 2 | ||||
| -rw-r--r-- | src/tape.zig | 4 | ||||
| -rw-r--r-- | src/terminal.zig | 2 | ||||
| -rw-r--r-- | src/tty/tty.zig | 10 |
5 files changed, 16 insertions, 4 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 6e01f8cd..2b1fae61 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -7873,7 +7873,7 @@ pub const Pardes = struct { // its shell's FIRST prompt, or never: typed later it would land // in whatever runs then, or in the middle of a line someone // typed (panes.terminal.greeting). - if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (panes.terminal.greeting(pane)) { + if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (tape.value(.prompt, panes.terminal.greeting, .{pane})) { .wait => {}, .never => pane.greet = false, .now => { diff --git a/src/replica.zig b/src/replica.zig index 95135307..8d8d47c5 100644 --- a/src/replica.zig +++ b/src/replica.zig @@ -598,6 +598,8 @@ pub const Replica = struct { c.in_len = 0; c.in_head = 0; tape.adoptCore(&r.t, c); + // Its keys into a terminal drawn at once (src/echo.zig). + c.echo = &r.echo; return r; } diff --git a/src/tape.zig b/src/tape.zig index b30096f5..f0766bd1 100644 --- a/src/tape.zig +++ b/src/tape.zig @@ -91,6 +91,10 @@ pub const Site = enum(u16) { pointer, /// What a terminal's ingest told the positions pardes keeps over it. positions, + /// Whether a terminal is at its prompt, as a step reads it after its + /// output (a greeting, a command waiting for the prompt): a + /// screen-state replica's emulator is the last delta's until the next. + prompt, }; /// Fields a host writes straight into the core between its calls. diff --git a/src/terminal.zig b/src/terminal.zig index 3a589659..2bc96a6e 100644 --- a/src/terminal.zig +++ b/src/terminal.zig @@ -463,7 +463,7 @@ pub fn shellSpawned(p: *Pardes, id: usize, prompt_marks: bool) void { pub fn releasePendingCommandIfReady(p: *Pardes, id: usize, pane: *Pane) void { if (pane.pending_command.wait == .input) - releasePendingCommand(p, id, pane, promptInputReady(pane)); + releasePendingCommand(p, id, pane, pardes.tape.value(.prompt, promptInputReady, .{pane})); } fn releasePendingCommand(p: *Pardes, id: usize, pane: *Pane, ready: bool) void { diff --git a/src/tty/tty.zig b/src/tty/tty.zig index e62da55c..b4eb6be9 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -1321,6 +1321,8 @@ const Remote = struct { _ = std.fmt.bufPrint(why, "the session's dump would not load: {t}\x00", .{err}) catch {}; return null; }; + // PARDES_NO_ECHO: no predicted echo (the gates' baseline). + if (std.c.getenv("PARDES_NO_ECHO") != null) r.echo.on = false; if (!r.loaded(joined.digest)) { r.deinit(); _ = std.fmt.bufPrint(why, "the session's dump loaded as another session (a build's dump is not complete)\x00", .{}) catch {}; @@ -1525,7 +1527,7 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se try startInput(&loop, &screen); defer stopInput(io, &screen.thread); (try std.Thread.spawn(.{}, winchWatch, .{&loop})).detach(); - if (link.check != null) (try std.Thread.spawn(.{}, wakeWatch, .{ io, &loop })).detach(); + (try std.Thread.spawn(.{}, wakeWatch, .{ io, &loop })).detach(); try screen.vx.queryTerminalSend(screen.tty.writer()); // A join a pass: the first, and one after the replica diverged or the // session let it go to upgrade. The terminal stays as it is. @@ -1544,6 +1546,8 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se sh.winched(); screen.vx.queueRefresh(); while (!link.quit) { + // Its predicted echo judged and caught up, once a frame. + if (r.echoFrame()) link.dirty = true; if (link.dirty) link.draw(&sh); const first = (loop.tryEvent() catch null) orelse idle: { // Idle, its frame drawn: the next key needs no copy taken. @@ -1565,7 +1569,9 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se screen.vx.queueRefresh(); link.dirty = true; } - if (link.owed) link.dirty = true; + if (link.owed or r.echo.changed) link.dirty = true; + // Predictions out: judged a frame at a time while they are. + if (r.echo.n > 0 or r.echo.cursor != null or r.echo.nd > 0) requestWake(io, @intCast(pardes.animation.frame_ns / std.time.ns_per_ms)); if (link.check != null) { // Quiet a while after a change: asked once (a wake, then the // next quiet one). |
