summaryrefslogtreecommitdiff
path: root/abi/term.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 03:03:55 -0300
committerGabriel Schneider <[email protected]>2026-11-22 10:31:04 -0300
commit9158de5d50831e115e14e2ed502300ee8c1d9930 (patch)
tree2b5e60569307e02d82b19bd419279392a6da257b /abi/term.zig
parent70c9e3fbf9cdc7139b4da0142f3a44741a7e1491 (diff)
downloadpardes-9158de5d50831e115e14e2ed502300ee8c1d9930.tar.gz
pardes-9158de5d50831e115e14e2ed502300ee8c1d9930.zip
term: screen_state.zig deleted, and the terminal module's side of the delta road (the old road's deletion, piece 5 of 8): core/term/screen_state.zig (1,213 lines: the encoder, tracks, peers' flights, a replica's apply and holes, its own soak and four tests) goes whole; core/term/terminal.zig loses `encode`/`encodeRows`/`encoder`/`encoderFree`/`track`/`untrack`/`replica`/`replicaFree`/`replicaTop`/`missing`/`apply`/`applyRows`/`shown`/`blank`, `takeMarks` (`marksOf` stays, private: the tests compare two terminals by it), the State's `changes` (a version's counter for the tracks), `read` with `markRead`/`wasRead`/`clearRead` (the rows a step read, for the fills), and `resize_to` with `resizeDeferred` and `resize`'s `later` (screen state's authority sized its terminals after a step's unit); abi/term.zig loses the `Encoder`/`Track`/`Replica` handles, `flight_bound`, `Peer`, `Applied` and those entries of `Ops` (and `dumpScreen`, which nothing in the core called); core/Term.zig its wrappers; core/term/term.zig its ops, its handle map and its `screen_state` export; core/panes.zig its `resizeDeferred` and resizes now (its later screen-state lines go in piece 6); core/edit.zig its `markRead`; the cell-for-cell dump the soak compares a client's terminal with its session's by moves to terminal.zig (`dumpScreen`, over the emulator), the soak's three streams (a shell's, a full-screen program's, `yes`) into test/replicas.zig, their one user; test/terminal.zig loses `a replica's terminal pane draws as its authority's does` (a delta's) and `a terminal made fresh has no size waiting` (`resize_to`'s); core-test 911/1068 (157 skipped), shell-test 1110/1113, term-test 15/15, pane-test 181/182 (again after the machines reboot, on a wiped cache), the soaks small run and `--echo` rc 0
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'abi/term.zig')
-rw-r--r--abi/term.zig86
1 files changed, 5 insertions, 81 deletions
diff --git a/abi/term.zig b/abi/term.zig
index 187b99e5..a0636509 100644
--- a/abi/term.zig
+++ b/abi/term.zig
@@ -1,8 +1,8 @@
//! The terminal as the core sees it (docs/next-terminal.md, Phase 1): the
//! entries (`Ops`) a terminal module gives the core, and the records they
-//! take and give. A terminal's state, its replicas' encoder and tracks are
-//! handles the core holds and never looks into; what it knows of them it is
-//! told here, as numbers, bytes, text and cells. core/term/term.zig is the
+//! take and give. A terminal's state is a handle the core holds and never
+//! looks into; what it knows of it it is told here, as numbers, bytes, text
+//! and cells. core/term/term.zig is the
//! one implementation (ghostty-vt behind it); core/Term.zig is the core's
//! side of it.
const std = @import("std");
@@ -12,12 +12,6 @@ const CellStyle = plain.CellStyle;
/// A terminal: its emulator, its parse and what is kept beside it.
pub const State = opaque {};
-/// What a session's authority keeps to encode its terminals for its peers
-/// (one for all of them), and what it keeps of one terminal for them.
-pub const Encoder = opaque {};
-pub const Track = opaque {};
-/// A replica's side of one terminal: what it was sent.
-pub const Replica = opaque {};
/// Where the view and the cursor are, in rows counted from the top of the
/// history: `total` rows, the view's top at `offset`, `len` of them shown.
@@ -35,7 +29,7 @@ pub const Grid = struct {
/// The view's top row while it is scrolled to one, null while it
/// follows the output.
view: ?usize = null,
- /// Its grid's width (a pane's may differ while a resize is deferred).
+ /// Its grid's width.
cols: u16 = 0,
};
@@ -240,50 +234,6 @@ pub const ImagesAt = struct {
/// marked it input, and its style's identity.
pub const EchoCell = struct { cp: u21, input: bool, style: u32 };
-// ---- its replicas ----
-
-/// Deltas a peer may have in flight. At 207 ms and 60 frames a second about
-/// 13 are; past the bound a peer gets nothing until an acknowledgement, and
-/// then the newest state, the ones between skipped.
-pub const flight_bound = 32;
-
-/// What the authority knows of one peer of one terminal.
-pub const Peer = struct {
- /// The version last sent, which the next delta is against; 0: none, so
- /// the next starts the replica afresh.
- sent: u32 = 0,
- /// The versions in flight, oldest first.
- flight: [flight_bound]u32 = undefined,
- n: u8 = 0,
- /// The history rows its replica holds as holes, absolute, as the
- /// replica keeps them (Replica.apply's rule, from what it was sent):
- /// what `fill` sends before a step reads them.
- top: u64 = 0,
- holes: std.ArrayListUnmanaged([2]u64) = .empty,
-
- pub fn deinit(peer: *Peer, gpa: std.mem.Allocator) void {
- peer.holes.deinit(gpa);
- }
-
- /// Every version up to `seq` has landed.
- pub fn ack(peer: *Peer, seq: u32) void {
- var i: u8 = 0;
- while (i < peer.n and peer.flight[i] <= seq) i += 1;
- std.mem.copyForwards(u32, peer.flight[0 .. peer.n - i], peer.flight[i..peer.n]);
- peer.n -= i;
- }
-
- /// Start the peer afresh: it lost its state, or never had one.
- pub fn reset(peer: *Peer) void {
- var holes = peer.holes;
- holes.clearRetainingCapacity();
- peer.* = .{ .holes = holes };
- }
-};
-
-/// A delta applied: its version, and what its authority sent beside it.
-pub const Applied = struct { seq: u32, extra: []const u8 };
-
/// What the dump keeps of a terminal beside its emulator, by name as every
/// dump is (core/walk.zig, through the core's `Term.State`).
pub const Parts = struct {
@@ -368,8 +318,7 @@ pub const Ops = struct {
viewTo: *const fn (s: *State, at: ?usize) void,
scroll: *const fn (s: *State, delta: i32) void,
follow: *const fn (s: *State) void,
- resize: *const fn (s: *State, cols: u16, rows: u16, later: bool) void,
- resizeDeferred: *const fn (s: *State) bool,
+ resize: *const fn (s: *State, cols: u16, rows: u16) void,
cellPixels: *const fn (s: *State, w: u32, h: u32) void,
replies: *const fn (s: *State) []const u8,
@@ -397,7 +346,6 @@ pub const Ops = struct {
/// How much of its row `row` (from the top of its history) the prompt
/// it starts with is; null for a row no prompt starts.
promptCut: *const fn (s: *State, row: i32) ?PromptCut,
- markRead: *const fn (s: *State) void,
/// What a predicted echo reads of cell `x`, `y` of its active area.
echoCell: *const fn (s: *const State, x: u16, y: u16) ?EchoCell,
@@ -419,28 +367,4 @@ pub const Ops = struct {
/// placeholder cells blanked in `frame` (`frame_cols` wide).
images: *const fn (s: *State, gpa: std.mem.Allocator, at: ImagesAt, out: *std.ArrayList(plain.Placement), frame: []plain.Cell, frame_cols: u16) void,
hasImages: *const fn (s: ?*const State) bool,
-
- // ---- its replicas ----
- encoder: *const fn (gpa: std.mem.Allocator) error{OutOfMemory}!*Encoder,
- encoderFree: *const fn (e: *Encoder) void,
- track: *const fn (gpa: std.mem.Allocator) error{OutOfMemory}!*Track,
- /// A peer's track of it let go (`s` null: it is gone).
- untrack: *const fn (t: *Track, gpa: std.mem.Allocator, s: ?*State) void,
- /// What a peer is owed of it, a delta against what the peer was sent.
- encode: *const fn (s: *State, e: *Encoder, t: *Track, peer: *Peer, out: *std.Io.Writer) anyerror!bool,
- /// Rows of it a replica holds as holes.
- encodeRows: *const fn (s: *State, e: *Encoder, t: *Track, lo: u64, hi: u64, out: *std.Io.Writer) anyerror!void,
- wasRead: *const fn (s: *const State) bool,
- clearRead: *const fn (s: *State) void,
- replica: *const fn (gpa: std.mem.Allocator) error{OutOfMemory}!*Replica,
- replicaFree: *const fn (r: *Replica, gpa: std.mem.Allocator) void,
- /// The absolute row its replica's active area begins at.
- replicaTop: *const fn (r: *const Replica) u64,
- /// History rows `lo..hi` it does not hold.
- missing: *const fn (r: *const Replica, lo: u64, hi: u64, out: *std.ArrayList([2]u64), gpa: std.mem.Allocator) error{OutOfMemory}!void,
- apply: *const fn (s: *State, r: *Replica, bytes: []const u8) anyerror!Applied,
- applyRows: *const fn (s: *State, r: *Replica, bytes: []const u8) anyerror!void,
- shown: *const fn (s: *State, r: *const Replica) [2]u64,
- blank: *const fn (s: *State, r: *const Replica, lo: u64, hi: u64) void,
- dumpScreen: *const fn (s: *State, w: *std.Io.Writer) error{WriteFailed}!void,
};