summaryrefslogtreecommitdiff
path: root/src/terminal.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 02:56:53 -0300
committerGabriel Schneider <[email protected]>2026-11-06 04:13:33 -0300
commitd1d5d3cfb18841604bba2057eeb3598f729b4475 (patch)
tree298c29ab8767852bf74eb86ad4d15acc4348f109 /src/terminal.zig
parent33037ece5af9ae1c7048819bbbae3fc5e6fc4ade (diff)
downloadpardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.tar.gz
pardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.zip
client #1, the views indexed: a view's share of the session is Pardes.View (the ~42 fields views.fields named: size, cell metrics, columns, rects, focus, jumps, pointer, gestures, prefixes, frontend), one of Pardes.views[4] (null when closed), the live one views[live] through Pardes.view() (index field `view` renamed `live`); going into another view is the index plus the panes' shares, which stay swapped (park and unpark now move only Pane.pv); views.zig loses fields, Part over Pardes, Parked, kept, emptied and the session half of every copy, and a pane closing leaves every view's layout at once (views.gone, at the two places a slot is freed) instead of the serials each parked view kept; drawOne and within put the drawn view's own share back whole; the views are in the digest now (tape's per-field parts name views[k].field), so a fresh view's col_x/col_w default to zeros, not undefined; the dump keeps every open view in the core and the panes' shares of the others under `shares`; an image from before (live view as the core's own fields, the rest under `views`) loads them into views[] once; the ~2,400 references rewritten mechanically from the compiler's errors (p.active is p.view().active, `const v = p.view()` hoisted in 823 places), Kind.zig (4 lines) and addon_test.zig (3) among them, macos.zig by pattern (not compiled here); tape's watched host writes read the live view's frontend and active; perf.zig's accessor lines change its harness hash, the debug baselines re-keyed to it (their numbers the base's); no golden changes; gates: core-test 956/956 both, unit-test 1487/1488 tui and 1530/1531 gui, behaviour-test 248/248 both, pane-test 171/172, snap all 105 ok, process-test 0 of 37 failed tui, replicas ok
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/terminal.zig')
-rw-r--r--src/terminal.zig42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/terminal.zig b/src/terminal.zig
index c9c60b5b..8204b0af 100644
--- a/src/terminal.zig
+++ b/src/terminal.zig
@@ -544,7 +544,7 @@ pub fn visibleCursor(pane: *const Pane) ?GridCursor {
/// many as keep its cursor's row in sight, as tmux pans a bigger window in
/// a smaller client. 0 in the view that sizes it, and in one tall enough.
pub fn panFor(p: *const Pardes, pane: *const Pane, r: pardes.Rect) u16 {
- if (pane.sized_by == p.view or pane.collapsed or !pane.isTerminal()) return 0;
+ if (pane.sized_by == p.live or pane.collapsed or !pane.isTerminal()) return 0;
const shown = r.h -| pane.tag_rows;
if (shown == 0 or shown >= pane.rows) return 0;
const state = pane.terminal orelse return 0;
@@ -2642,7 +2642,7 @@ test "terminal Filter keys indexed truecolor OSC and background-only cells throu
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = p.bodyTop(pane, r);
@@ -2783,7 +2783,7 @@ test "terminal Filter preserves exact palette-null light theme default roles" {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = p.bodyTop(pane, r);
const ordinary = try p.render(frame.allocator());
@@ -2842,7 +2842,7 @@ test "terminal Filter refuses a foreground that would collapse onto the page" {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = p.bodyTop(pane, r);
@@ -2934,7 +2934,7 @@ test "tty ansi colors follow the prompt hug into normal mode" {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = p.bodyTop(pane, r);
const red: pardes.Color = .{ .rgb = p.theme().palette.?[1] };
@@ -2971,7 +2971,7 @@ test "a prompt row hidden end to end paints nothing at all" {
var frame = std.heap.ArenaAllocator.init(testing.allocator);
defer frame.deinit();
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = p.bodyTop(pane, r);
p.shell_rows.stale = true;
@@ -3060,8 +3060,8 @@ fn syncPixels(p: *const Pardes, pane: *Pane) void {
if (comptime !images_enabled) return;
const state = pane.terminal orelse return;
const vt = &state.vt;
- vt.width_px = @as(u32, vt.cols) * p.cell_pixels.w;
- vt.height_px = @as(u32, vt.rows) * p.cell_pixels.h;
+ vt.width_px = @as(u32, vt.cols) * p.view().cell_pixels.w;
+ vt.height_px = @as(u32, vt.rows) * p.view().cell_pixels.h;
}
/// When the pane's next kitty animation frame is due (ms on the core's
@@ -3153,7 +3153,7 @@ test "a program that asked for focus reports hears CSI I and CSI O as its pane t
var out: std.ArrayList(u8) = .empty;
defer out.deinit(gpa);
_ = try ptyWritesByPane(p, &out);
- p.active = 0;
+ p.view().active = 0;
// Asking while its pane has the keyboard: told at once that it has.
p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1004h" } });
try std.testing.expectEqualStrings("0:\x1b[I\n", try ptyWritesByPane(p, &out));
@@ -3161,12 +3161,12 @@ test "a program that asked for focus reports hears CSI I and CSI O as its pane t
try std.testing.expectEqualStrings("", try ptyWritesByPane(p, &out));
// A click into the other pane moves the keyboard: out of one, into the
// other.
- const r = p.rects[1];
+ const r = p.view().rects[1];
const at_col = r.x + config.GUTTER + 2;
const at_row = p.bodyTop(p.panes[1].?, r) + 1;
p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = at_col, .row = at_row } });
p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = at_col, .row = at_row } });
- try std.testing.expectEqual(@as(usize, 1), p.active);
+ try std.testing.expectEqual(@as(usize, 1), p.view().active);
try std.testing.expectEqualStrings("0:\x1b[O\n1:\x1b[I\n", try ptyWritesByPane(p, &out));
// The window: away and back.
p.update(.{ .focus = false });
@@ -3176,7 +3176,7 @@ test "a program that asked for focus reports hears CSI I and CSI O as its pane t
p.update(.{ .focus = true });
try std.testing.expectEqualStrings("1:\x1b[I\n", try ptyWritesByPane(p, &out));
// A program that did not ask hears nothing: pane 2.
- p.active = 2;
+ p.view().active = 2;
p.update(.tick);
try std.testing.expectEqualStrings("1:\x1b[O\n", try ptyWritesByPane(p, &out));
}
@@ -3203,8 +3203,8 @@ test "a terminal's kitty graphics image is drawn where its program placed it, an
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .shells = 1 });
defer p.deinit();
- p.frontend.native_images = true;
- p.active = 0;
+ p.view().frontend.native_images = true;
+ p.view().active = 0;
p.update(.{ .resize = .{ .cols = 80, .rows = 24, .cell_pixels = .{ .w = 10, .h = 20 } } });
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
@@ -3215,7 +3215,7 @@ test "a terminal's kitty graphics image is drawn where its program placed it, an
const places = imagePlaces(s);
try std.testing.expectEqual(@as(usize, 1), places.len);
const place = places[0];
- const r = p.rects[0];
+ const r = p.view().rects[0];
const img = pane.terminal.?.vt.screens.active.kitty_images.imageById(7).?;
try std.testing.expectEqual(pardes.Placement.keyOf(pane.serial, 7, @truncate(img.generation)), place.key);
try std.testing.expectEqual(pardes.RectCell{ .x = r.x + config.GUTTER + 4, .y = p.bodyTop(pane, r) + 2, .w = 2, .h = 1 }, place.dst);
@@ -3257,7 +3257,7 @@ test "ED 3 takes away a kitty placement whose row it erased: it never comes back
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .shells = 1 });
defer p.deinit();
- p.frontend.native_images = true;
+ p.view().frontend.native_images = true;
p.update(.{ .resize = .{ .cols = 80, .rows = 24, .cell_pixels = .{ .w = 10, .h = 20 } } });
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
@@ -3324,7 +3324,7 @@ test "a virtual kitty placement shows through its placeholder cells, which draw
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .shells = 1 });
defer p.deinit();
- p.frontend.native_images = true;
+ p.view().frontend.native_images = true;
p.update(.{ .resize = .{ .cols = 80, .rows = 24, .cell_pixels = .{ .w = 10, .h = 20 } } });
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
@@ -3338,7 +3338,7 @@ test "a virtual kitty placement shows through its placeholder cells, which draw
const s = try p.render(frame.allocator());
const places = imagePlaces(s);
try std.testing.expectEqual(@as(usize, 1), places.len);
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const y = p.bodyTop(pane, r) + 1;
try std.testing.expectEqual(pardes.RectCell{ .x = tx + 2, .y = y, .w = 2, .h = 1 }, places[0].dst);
@@ -3358,13 +3358,13 @@ test "a terminal's image is a placement whatever the frontend draws, and the Pet
const pane = p.panes[0].?;
pane.body.mode = .tty;
p.update(.{ .output = .{ .pane = 0, .bytes = kittyTransmit("c=2,r=1") } });
- const r = p.rects[0];
+ const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const y = p.bodyTop(pane, r);
// A frontend that draws no pixels (a tty under no kitty graphics) is
// handed the picture all the same, and the cells under it are its.
- p.frontend.native_images = false;
+ p.view().frontend.native_images = false;
var s = try p.render(frame.allocator());
try std.testing.expectEqual(@as(usize, 1), imagePlaces(s).len);
try std.testing.expect(!imagePlaces(s)[0].art.glyph);
@@ -3374,7 +3374,7 @@ test "a terminal's image is a placement whatever the frontend draws, and the Pet
try std.testing.expect(std.mem.indexOf(u8, try tagline.tagPrefix(p, pane), " petscii:on") != null);
// The builtin flips the pane to glyph art and back.
- p.frontend.native_images = true;
+ p.view().frontend.native_images = true;
try std.testing.expect(p.executeBuiltinLine(0, "Petscii"));
_ = frame.reset(.retain_capacity);
s = try p.render(frame.allocator());