summaryrefslogtreecommitdiff
path: root/core/body_layer.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 17:55:03 -0300
committerGabriel Schneider <[email protected]>2026-11-22 19:48:03 -0300
commit8e850e6c923dcd84b7a5483f73377bd192b94a2b (patch)
tree0730a84095f75d8a46e4dcdfebddb8d8b90af7c6 /core/body_layer.zig
parentbad506bd45846e012246a33b5d3097b3e92f02bc (diff)
downloadpardes-8e850e6c923dcd84b7a5483f73377bd192b94a2b.tar.gz
pardes-8e850e6c923dcd84b7a5483f73377bd192b94a2b.zip
terminals: where a view stands in a terminal's history is the view's, not the emulator's (pardes-term-join-10, item 1; the note's point 3, the coordinator's choice): `Pane.scrolled_to` (core/panes.zig), a per-view field (views.zig `pane_fields`, `PaneView`: in the rollback copy, the digest and the dump, each view's own), the row its top shows or null on the output, written only by a step (`scrollBy`, `followOutput`), and carried with every open view's through each write of the emulator that moves rows, once, in the confirmed unit's apply, on every side alike (`Term.feed`/`Term.resize` take the places; core/term/terminal.zig `carry`/`carried` pin each place's row on the primary screen and read the pin back: up by the rows the history drops, 0 when its own row goes, null in the active area or after a reset: a function of the fed bytes); the draw reads the rows from the view's place (`viewport`, `paint`, `ImagesAt.place`, terminal.zig `shown`), and ghostty's own viewport is never moved, read, digested or dumped (`Grid.offset`/`view`, `Parts.view` and the digest's offset gone): two clients no longer scroll one viewport (the new views.zig test failed on the base, `expected 80, found 77`), and a speculation's scroll is in the copy, so `putViews`, the view half of `keepViews` (now `keepSerials`), `viewTo`/`scroll`/`follow` (ops, wrappers, bodies), the Debug screen hash's view exclusion, `reflow`'s column-0 cure and `feedOutput`'s follow-after-read are deleted, and S1's `calls` lists no view write (the rows `viewTo`, `scroll`, `follow` gone); tests: the two-view test (with a dump), the place at the history's cap (`setMaxBytes(1)`), a 300-seed fuzz of the carried place against ghostty's own pinned view, a client's wheel over a shared terminal through output and a rollback, round 6's order explorer (30 seeds a run); the wire at 31 (abi/wire.zig, test/daemon.py `WIRE`): an installed build's dump loads with every view on the output; IN THE WORKSPACE core-test 912/1072 (160 skipped), shell-test 1114/1117 (3 skipped), term-test 16/16, kitty-test 45/45, pane-test 181/182, behaviour-test 275/275, --replay 275/275, process-test 0 of 146 failed, as pairs 0 of 146; gui unit-test 1707/1711, its one error BaselineHarnessMismatch (every base's)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/body_layer.zig')
-rw-r--r--core/body_layer.zig19
1 files changed, 10 insertions, 9 deletions
diff --git a/core/body_layer.zig b/core/body_layer.zig
index 817176bb..cb518af4 100644
--- a/core/body_layer.zig
+++ b/core/body_layer.zig
@@ -38,7 +38,7 @@ fn paintTerminalSelection(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, rows: [
var visible: i32 = 0;
while (lines.next()) |line| : (visible += 1) {
if (visible >= r.h -| pane.tag_rows) break;
- const source_row = if (raw) @as(i32, @intCast(panes.Term.grid(pane.terminal).offset)) + visible else pane.wrapAt(p.settings.tab, visible).line;
+ const source_row = if (raw) @as(i32, @intCast(pane.termTop())) + visible else pane.wrapAt(p.settings.tab, visible).line;
for (rows) |row| {
const target = if (row.raw_terminal)
(if (raw) row.row else pane.surfRow(row.row))
@@ -497,7 +497,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
if (active and pane.focus == .body and (pane.prompt == .none or pane.prompt == .del_side or pane.prompt == .repl_choice)) {
if (pane.body.mode != .tty) {
const grid = panes.Term.grid(pane.terminal);
- const crow = if (pane.body.cur_pinned) pane.body.cur_row else pane.surfRow(@as(i32, grid.cursor_y) + @as(i32, @intCast(grid.offset)));
+ const crow = if (pane.body.cur_pinned) pane.body.cur_row else pane.surfRow(@as(i32, grid.cursor_y) + @as(i32, @intCast(pane.termTop())));
const ccol = if (pane.body.cur_pinned) pane.body.cur_col else @as(i32, grid.cursor_x);
const cwp = pane.wrapRow(p.settings.tab, crow, ccol);
const prow = cwp.row + @as(i32, pane.tag_rows);
@@ -528,8 +528,9 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
const grid = panes.Term.grid(pane.terminal);
if (!grid.cursor_visible) break :visible;
const row = grid.total - grid.len + grid.cursor_y;
- if (row < grid.offset + pane.pan or row - grid.offset >= grid.len) break :visible;
- const y: u16 = @intCast(row - grid.offset - pane.pan);
+ const top = pane.termTop();
+ if (row < top + pane.pan or row - top >= grid.len) break :visible;
+ const y: u16 = @intCast(row - top - pane.pan);
if (y + pane.tag_rows < body_bottom and grid.cursor_x < tw)
s.cursor = .{ .x = tx + grid.cursor_x, .y = body_y + y };
}
@@ -557,7 +558,7 @@ pub fn bodyText(tab: u16, arena: std.mem.Allocator, pane: *Pane) ![]const u8 {
if (pane.file) |*f| return panes.File.bodyText(tab, arena, pane, f);
// A terminal's: the rows its view shows (outside raw mode its prompts
// cut off), the edit copy's lines over the rows the copy covers.
- const vp: []const []const u8 = if (pane.terminal) |state| try panes.Term.viewport(state, arena, pane.body.mode != .tty) else &.{};
+ const vp: []const []const u8 = if (pane.terminal) |state| try panes.Term.viewport(state, arena, pane.body.mode != .tty, pane.scrolled_to) else &.{};
const len = fillBody(null, pane, vp);
const out = try arena.alloc(u8, len);
const filled = fillBody(out, pane, vp);
@@ -570,9 +571,9 @@ pub const BodyRow = union(enum) {
edit: struct { line: []const u8, idx: usize },
};
-/// A terminal pane's body rows, top down: a row of its emulator's view
-/// (`grid`, its viewport row), or a line of the edit copy standing in for
-/// the rows it covers (`edit`).
+/// A terminal pane's body rows, top down: a row of this view of its
+/// emulator (`grid`, counted from the view's top), or a line of the edit
+/// copy standing in for the rows it covers (`edit`).
pub const BodyWalk = struct {
pane: *Pane,
goff: i32,
@@ -586,7 +587,7 @@ pub const BodyWalk = struct {
pub fn init(pane: *Pane) BodyWalk {
const off = pane.scroll();
- const goff: i32 = @intCast(panes.Term.grid(pane.terminal).offset);
+ const goff: i32 = @intCast(pane.termTop());
return .{
.pane = pane,
.goff = goff,