diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 20:21:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 20:21:32 -0300 |
| commit | 3f250d0f963f375d699f11ffc02b07f2e2cbbbee (patch) | |
| tree | 4e5a1f577fd3dd247f3643d979868347524ce703 /core/Term.zig | |
| parent | 34e2d82a322bd3767a8ec62b3a4c0894399e8c04 (diff) | |
| parent | c607dc14502a6956bdfa3575bc7363514a7abeb4 (diff) | |
| download | pardes-3f250d0f963f375d699f11ffc02b07f2e2cbbbee.tar.gz pardes-3f250d0f963f375d699f11ffc02b07f2e2cbbbee.zip | |
integration (a base for the terminals' next round, not yet the gathered line): the viewport in the view and the patches in the semantics hash on merge58 with the terminal put back: pardes-raw-tty (`muwnrqro`, on pardes-merge58: a TERM that reaches a session while it leaves its terminal no longer leaves it raw: `Killed.disarm` puts the cooked modes back itself, `leave` calls it last) and pardes-term-join-10's two changes (`xktusoyq` on `qtxssxyk`, on pardes-term-join-9: where a view stands in a terminal's history is the view's (`Pane.scrolled_to`), carried once a confirmed write that moves rows, the wire at 31; build/patches hashed into a replica's semantics); no conflict; core-test 917/1077 (160 skipped), shell-test 1119/1122, pane-test 182/183, term-test 16/16; NOT gated whole: the viewport's gate had one perf count over its budget ("terminal on all" +0.235%), which the next round brings down before this is the gathered line (2026-11-22)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Term.zig')
| -rw-r--r-- | core/Term.zig | 82 |
1 files changed, 30 insertions, 52 deletions
diff --git a/core/Term.zig b/core/Term.zig index 580db4fa..b82017f6 100644 --- a/core/Term.zig +++ b/core/Term.zig @@ -14,8 +14,8 @@ const dump = @import("dump.zig"); const File = @import("File.zig"); const iface = plain.term; -/// Writes into this process's emulators (a read fed, a grid reflowed, a -/// view moved, one opened, closed, loaded or made again): whether a unit's +/// Writes into this process's emulators (a read fed, a grid reflowed, one +/// opened, closed, loaded or made again): whether a unit's /// replay made one, the replica engine's one rule (core/replica.zig /// `confirm`) reads across that replay, on its one thread. pub var writes: u32 = 0; @@ -69,12 +69,7 @@ pub const State = struct { /// The emulator as its program has made it, for the replay digest. pub fn digest(s: *const State, h: *walk.Hasher) void { - s.digestScreen(h, true); - } - - /// `view`: where its view is too (a replica's speculation may move it). - pub fn digestScreen(s: *const State, h: *walk.Hasher, view: bool) void { - the().digest(s.impl, h, view); + the().digest(s.impl, h); } pub fn dumpWrite(s: *const State, gpa: std.mem.Allocator, w: *std.Io.Writer) !void { @@ -191,45 +186,29 @@ pub fn stop() void { if (ops) |o| o.stop(); } -// ---- output and view ---- +// ---- output and size ---- /// One read of its program's output (`Told` says where the tracked rows -/// went). -pub fn feed(s: *State, bytes: []const u8, tracked: []const i32, rows: []i32, erased: []bool) Told { +/// went), every view's place in its history carried through it (`resize`). +pub fn feed(s: *State, bytes: []const u8, tracked: []const i32, rows: []i32, erased: []bool, places: []?usize) Told { writes +%= 1; s.written = true; - return the().feed(s.impl, bytes, tracked, rows, erased); + return the().feed(s.impl, bytes, tracked, rows, erased, places); } -/// Where the view and the cursor are; all zero without a terminal. +/// How much history it has and where its cursor is; all zero without a +/// terminal. Where a view stands in it is the view's (Pane.scrolled_to). pub fn grid(s: ?*const State) Grid { const o = ops orelse return .{}; return o.grid(if (s) |state| state.impl else null); } -/// Its view to a row of its history, or onto its output (null). -pub fn viewTo(s: *State, at: ?usize) void { - writes +%= 1; - the().viewTo(s.impl, at); -} - -/// Its view moved by a number of rows (negative scrolls back). -pub fn scroll(s: *State, delta: i32) void { - writes +%= 1; - the().scroll(s.impl, delta); -} - -/// Its view back onto its output. -pub fn follow(s: *State) void { - writes +%= 1; - the().follow(s.impl); -} - -/// Its grid reflowed. -pub fn resize(s: *State, cols: u16, rows: u16) void { +/// Its grid reflowed, every view's place in its history (Pane.scrolled_to, +/// each view's) carried through it as ghostty carries a view of its own. +pub fn resize(s: *State, cols: u16, rows: u16, places: []?usize) void { writes +%= 1; s.written = true; - the().resize(s.impl, cols, rows); + the().resize(s.impl, cols, rows, places); } /// Its cells' size in pixels (kitty graphics, CSI 14/16 t). @@ -275,8 +254,8 @@ pub fn modes(s: ?*const State) Modes { return o.modes(if (s) |state| state.impl else null); } -/// How far left or right a click on the prompt line moves the shell's -/// cursor, at the prompt the cursor is at. +/// How far left or right a click on the prompt line (its row from the top of +/// the history) moves the shell's cursor, at the prompt the cursor is at. pub fn promptMoves(s: *State, row: i32, col: i32) ?Moves { return the().promptMoves(s.impl, row, col); } @@ -324,9 +303,10 @@ pub fn textRows(s: *State, alloc: std.mem.Allocator, scratch: std.mem.Allocator) return the().textRows(s.impl, alloc, scratch); } -/// The rows its view shows as text, prompts cut off or not. -pub fn viewport(s: *State, arena: std.mem.Allocator, cut: bool) iface.TextError![]const []const u8 { - return the().viewport(s.impl, arena, cut); +/// The rows a view at `place` (Pane.scrolled_to) shows as text, prompts +/// cut off or not. +pub fn viewport(s: *State, arena: std.mem.Allocator, cut: bool, place: ?usize) iface.TextError![]const []const u8 { + return the().viewport(s.impl, arena, cut, place); } /// Its rows `first` and the `count` after it as text, prompts cut off (the @@ -386,10 +366,11 @@ pub fn spanColor(f: *Filter, color: plain.Color, is_bg: bool) plain.Color { // images as placements; which of the body's rows they stand under is the // core's (core/ansi.zig). -/// Its view's rows from `first`, `rows.len` of them, as cells in the -/// theme's colours, through the theme's filter when the pane has it on. -pub fn paint(s: *State, ink: *const Ink, palette: *FilterPalette, filtered: bool, first: u16, cols: u16, cells: []Painted, rows: []PaintedRow) void { - the().paint(s.impl, ink, palette, filtered, first, cols, cells, rows); +/// The rows a view at `place` (Pane.scrolled_to) shows from its row +/// `first`, `rows.len` of them, as cells in the theme's colours, through +/// the theme's filter when the pane has it on. +pub fn paint(s: *State, ink: *const Ink, palette: *FilterPalette, filtered: bool, place: ?usize, first: u16, cols: u16, cells: []Painted, rows: []PaintedRow) void { + the().paint(s.impl, ink, palette, filtered, place, first, cols, cells, rows); } /// Its kitty graphics over the body's rows, as placements. @@ -422,16 +403,13 @@ pub const calls = [_]struct { []const u8, []const u8, []const u8 }{ .{ "close", "panes.zig:1", "WRITE: let go by a step that closes its pane: a copy held across it is let go (retiring panes); a unit that closes one is never kept over a copy" }, .{ "revive", "dump.zig:1", "WRITE: a load's (a join's dump, a Restore): no copy is held" }, .{ "reload", "panes.zig:1", "WRITE: a join's step remakes each terminal written since its last reload, on every side (panes.reloadTerminals, the session's choice taped, the snapshot's hash compared)" }, - .{ "feed", "keys.zig:1 panes.zig:3", "WRITE: the pty's bytes in a unit, every side in the tape's order; a unit that feeds lets a copy held ahead go (`Term.writes`), so none is replayed (keys.zig's: a test's)" }, - .{ "viewTo", "replica.zig:2", "WRITE: a rollback puts each view back by its row (`putViews`), exact since a reflow keeps a view a row (pardes-term-join-6)" }, - .{ "scroll", "Core.zig:2 panes.zig:1", "WRITE: a step moves the view; outside the copy, put back by `putViews`" }, - .{ "follow", "panes.zig:1", "WRITE: a step puts the view on the output; put back by `putViews`" }, - .{ "resize", "panes.zig:1", "WRITE: a step's reflow; a speculation owes it (`touchTerminal`): its input is taken when confirmed, never as speculated" }, + .{ "feed", "keys.zig:1 panes.zig:3", "WRITE: the pty's bytes in a unit, every side in the tape's order, every view's place (Pane.scrolled_to, in the copy) carried through it; a unit that feeds lets a copy held ahead go (`Term.writes`), so none is replayed (keys.zig's: a test's)" }, + .{ "resize", "panes.zig:1", "WRITE: a step's reflow, every view's place carried through it; a speculation owes it (`touchTerminal`): its input is taken when confirmed, never as speculated" }, .{ "endOutputHere", "ninep/pty.zig:1", "WRITE: a 9P pty/run's step ends a command's output at the cursor: the session's step, replayed as such" }, .{ "replies", "Core.zig:1", "WRITE: a step drains the reply buffer (in the digest); only the session writes it to the pty (pty_write is off the tape)" }, // ---- reads by a step: in the digest ---- - .{ "grid", "Core.zig:8 ansi.zig:4 body_layer.zig:5 draw.zig:3 dump.zig:4 echo.zig:8 edit.zig:1 exec.zig:3 keys.zig:3 layout.zig:2 mouse.zig:1 panes.zig:6 replica.zig:4", "READ: the size, the view, the cursor: in the digest (ansi.zig, body_layer.zig, draw.zig, echo.zig: a draw's)" }, - .{ "modes", "Core.zig:5 draw.zig:1 dump.zig:2 echo.zig:3 exec.zig:3 mouse.zig:4 ninep/pty.zig:3 replica.zig:1", "READ: the program's modes (mouse, focus, bracketed paste, the alternate screen): in the digest (draw.zig, echo.zig: a draw's)" }, + .{ "grid", "Core.zig:2 ansi.zig:3 body_layer.zig:3 draw.zig:2 dump.zig:4 echo.zig:8 exec.zig:2 layout.zig:2 panes.zig:5 replica.zig:2", "READ: the size, the history's length, the cursor: in the digest (a view's place is its pane's; ansi.zig, body_layer.zig, draw.zig, echo.zig: a draw's)" }, + .{ "modes", "Core.zig:5 draw.zig:1 dump.zig:2 echo.zig:3 exec.zig:3 mouse.zig:4 ninep/pty.zig:3 panes.zig:2 replica.zig:1", "READ: the program's modes (mouse, focus, bracketed paste, the alternate screen): in the digest (draw.zig, echo.zig: a draw's; panes.zig: a view scrolls no history on the alternate screen)" }, .{ "prompt", "Core.zig:1 builtins.zig:1 echo.zig:1 exec.zig:3 ninep/pty.zig:1 panes.zig:1", "READ: the OSC 133 cycle: in the digest (`marksOf`); Core.zig's and ninep/pty.zig's also taped (`.prompt`, each side's compared)" }, .{ "promptPrefix", "body_layer.zig:1 edit.zig:1 exec.zig:1", "READ: a row's prompt cells (`promptCut`): the active area's in the digest; a history row's text is not (below)" }, .{ "hasImages", "replica.zig:3 tagline.zig:1", "READ: whether it holds a kitty image (the tag's prefix): in the digest" }, @@ -448,7 +426,7 @@ pub const calls = [_]struct { []const u8, []const u8, []const u8 }{ .{ "scrollbackLen", "ninep/ctl.zig:1 ninep/pane.zig:1", "READ, NOT COVERED: the history's text's length (its row count is in the digest)" }, .{ "commandOutput", "ninep/pty.zig:1", "READ, NOT COVERED: a command's output rows (a 9P pty/run): taped as the session's answer" }, .{ "textRows", "edit.zig:2", "READ, NOT COVERED: every row's text, the history's among them (a selection, a Look over a shell)" }, - .{ "viewport", "body_layer.zig:1 replica.zig:1", "READ: the view's rows' text (body_layer.zig: a draw's; replica.zig: a test's)" }, + .{ "viewport", "body_layer.zig:1 replica.zig:1", "READ: the rows' text a view's place (in the digest, with its pane) shows (body_layer.zig: a draw's; replica.zig: a test's)" }, .{ "editRows", "ansi.zig:1", "READ: rows' text for a draw" }, // ---- local ---- .{ "due", "Core.zig:1", "LOCAL: its next wake (a blink, an animation): the loop's, never a step's state" }, @@ -457,7 +435,7 @@ pub const calls = [_]struct { []const u8, []const u8, []const u8 }{ .{ "paint", "ansi.zig:1", "LOCAL: its cells drawn" }, .{ "images", "ansi.zig:1", "LOCAL: its kitty images drawn" }, .{ "start", "tape.zig:1", "LOCAL: the module's start, a test's (its own process's)" }, - .{ "emulatorOf", "Core.zig:2 ninep/pty.zig:3", "the module's state itself: tests only" }, + .{ "emulatorOf", "Core.zig:2 ninep/pty.zig:3 replica.zig:1", "the module's state itself: tests only" }, }; test "every call of the core's into a terminal is listed with its rule (S1): a new read, writer or local use fails until it is" { |
