diff options
Diffstat (limited to 'src/tape.zig')
| -rw-r--r-- | src/tape.zig | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/tape.zig b/src/tape.zig index c617f2a2..fd5b4b85 100644 --- a/src/tape.zig +++ b/src/tape.zig @@ -21,7 +21,6 @@ const std = @import("std"); const pardes = @import("pardes.zig"); const walk = @import("walk.zig"); const host_io = @import("host_io.zig"); -const terminal = @import("terminal.zig"); const Pardes = pardes.Pardes; const VTable = pardes.Host.VTable; const libc = std.c; @@ -136,8 +135,8 @@ pub const results = .{ ?std.Io.File.Kind, ?pardes.filesystem.Resolved, pardes.filesystem.OsReadWrite, anyerror!pardes.filesystem.OsStat, anyerror![]const u8, anyerror![]u8, - anyerror!void, terminal.Told, - ?pardes.ctlfs.pty.Printed, @typeInfo(@TypeOf(terminal.greeting)).@"fn".return_type.?, + anyerror!void, pardes.Term.Told, + ?pardes.ctlfs.pty.Printed, @typeInfo(@TypeOf(pardes.panes.Pane.greeting)).@"fn".return_type.?, []pardes.Stream.Batch, // What only the authority holds (`authority`): a closed pane's record, // Recent's entry for a closed jump, the closed panes' names. @@ -253,7 +252,7 @@ pub const Tape = struct { dump_check: bool = false, dumps: usize = 0, dump_bytes: usize = 0, - /// Screen-state terminals (src/screen_state.zig, docs/next-daemon.md + /// Screen-state terminals (src/term/screen_state.zig, docs/next-daemon.md /// phase 5): an authority recording for replicas, or a replica. A /// terminal's emulator is the authority's alone: its output is recorded /// without its bytes (they cross as screen state), its pty writes are @@ -1062,6 +1061,27 @@ pub fn poison(why: []const u8) void { }; } +/// A replica's speculation leaves what is the authority's be (a terminal's +/// emulator, a kind's state): true, and the input waits for its order. +pub fn authorityOnly(comptime why: []const u8) bool { + if (!speculating()) return false; + poison(why); + return true; +} + +/// A speculation that moves a terminal's view: a screen-state replica's +/// may (its rollback puts the view back, replica.zig `views`, and a delta +/// sets it), any other stops (`authorityOnly`). +pub fn viewOnly(comptime why: []const u8) bool { + if (!speculating()) return false; + if (screenState()) { + touchTerminal(); + return false; + } + poison(why); + return true; +} + /// A speculation read a terminal's rows or moved its view (`Tape.touched`). pub fn touchTerminal() void { if (on) |t| if (t.speculating) { @@ -1247,7 +1267,7 @@ pub fn startFromEnv() void { pub fn replayMain(path: []const u8) u8 { const gpa = std.heap.c_allocator; // What a shell starts before its core (tui.zig's localSession). - pardes.TerminalImages.start(gpa); + pardes.Term.start(gpa); pardes.syntax.start(gpa); const bytes = std.Io.Dir.cwd().readFileAlloc(std.Io.Threaded.global_single_threaded.io(), path, gpa, .unlimited) catch |err| { std.debug.print("replay: cannot read {s}: {t}\n", .{ path, err }); |
