diff options
Diffstat (limited to 'core/panes.zig')
| -rw-r--r-- | core/panes.zig | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/core/panes.zig b/core/panes.zig index 72ca3eea..fd152e1e 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -125,6 +125,12 @@ pub const Pane = struct { pub const Focus = enum { body, tag }; pub const SessionView = struct { wrap: bool = true, layered: bool = true, body_h: u32 = 0, tagline_h: u32 = 0, rect_h: u16 = 0 }; terminal: ?*Term.State = null, + /// Its terminal's, kept by the pane, which a rollback puts back, not by + /// the emulator, which none does (a speculation writes them): the grid + /// cell its program last heard the mouse at (motion is told once a + /// cell), and its kitty graphics drawn as glyph art (Petscii). + term_mouse: ?Term.Coordinate = null, + term_petscii: bool = false, gpa: std.mem.Allocator, serial: u32 = 0, /// What the control filesystem keeps of this pane -- addr and limit, the @@ -960,15 +966,17 @@ pub const Pane = struct { /// replica by its authority (the next delta says), on such an authority /// once the step's unit is out (`resizeDeferred`). pub fn resizeGrid(pane: *Pane, cols: u16, rows: u16) void { - // A screen-state client's speculation does what its replay does - // (its selections, never the grid): it waits for no round trip. - if (!tape.screenState() and tape.authorityOnly("resize a terminal")) return; + // A client's speculation does what its replay does (its + // selections) but the grid: it waits for no round trip. Under bytes + // it owes the grid (`touchTerminal`): its input is replayed when + // confirmed, never taken as speculated (replica.zig `confirm`). const state = pane.terminal orelse return; if (cols != pane.cols) for (0..pane.sel.len) |button| { pane.clearPointerSelection(button); pane.sel[button].state = .none; }; if (tape.screenReplica()) return; + if (tape.speculating()) return tape.touchTerminal(); // A client typing at another size than the last typist's read // history rows its replay held as holes, and the rows came // renumbered (2026-10-30): the authority's waits for the unit. @@ -1111,6 +1119,31 @@ pub const Term = @import("Term.zig"); /// not follow the output (no memory for its pin), so it was reset. pub const positions_lost = "terminal edit position reset: out of memory"; +/// At a join (Core's openView, rejoinView): under bytes, every live +/// terminal made again from its own snapshot, on every side alike, the +/// session included (Term.reload): an emulator loaded from a snapshot holds +/// its rows in other pages than one fed from its start, and ghostty prunes +/// its history a page at a time, so the joiner, loaded from the session's +/// dump made next, and the replicas there before it, would part. The +/// session's snapshot's hash is taped, and each replica's own compared +/// with it: a check of the whole emulator at every join. +pub fn reloadTerminals(p: *Pardes) void { + if (tape.screenState()) return; + for (p.panes) |slot| if (slot) |pane| if (pane.terminal) |state| { + // Its cells' size in pixels as a feed sets it (`feedOutput`): a + // frontend's draw sets its own view's between steps (ansi.zig), a + // window's other than a terminal's, and the snapshot holds it. + Term.cellPixels(state, p.view().cell_pixels.w, p.view().cell_pixels.h); + const mine: ?u64 = Term.reload(state) catch null; + p.shell_rows.markStale(pane); + if (tape.value(.reload, sameHash, .{mine}) != mine) tape.diverged("a terminal reloaded at a join is not the session's"); + }; +} + +fn sameHash(h: ?u64) ?u64 { + return h; +} + /// The sizes steps gave terminals (`Pane.resizeGrid`), made: between /// units, on an authority with screen-state replicas (replica.Peers.unit). pub fn resizeDeferred(p: *Pardes) void { @@ -1141,16 +1174,17 @@ pub fn createTerminal(gpa: std.mem.Allocator, cols: u16, rows: u16) !*Pane { return pane; } -/// A screen-state replica's emulators' allocator (`Term.State.gpa`): the C -/// heap, outside its rollback epoch: written by deltas while a copy is -/// held, no part of it is ever a copy's to save or put back. +/// A replica's emulators' allocator (`Term.State.gpa`): the C heap, +/// outside its rollback epoch: written (by the session's bytes or deltas) +/// while a copy is held, no part of it is ever a copy's to save or put +/// back, or the pages an emulator gains then are freed with the copy. pub const emulator_gpa = std.heap.c_allocator; /// What a terminal's emulator is made with, by `createTerminal` or a pane's /// load (dump.loadPane, a closed terminal brought back): `gpa`, but on a -/// screen-state replica `emulator_gpa`. +/// replica `emulator_gpa`. pub fn emulatorGpa(gpa: std.mem.Allocator) std.mem.Allocator { - return if (tape.screenReplica()) emulator_gpa else gpa; + return if (tape.replaying()) emulator_gpa else gpa; } // ---- the session's pane slots: making, finding, closing and freeing panes, and their prompts ---- |
