summaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 14:38:59 -0300
committerGabriel Schneider <[email protected]>2026-11-24 14:53:41 -0300
commit552400589c0514e8e3f9a9f96b23d2224302e1a7 (patch)
tree3e2cf528b9b3ecd503bfc25740d8577e4222c8c9 /dev
parenta19eb53fa9ade764a1cf2e3c320cd34d50aa4106 (diff)
downloadpardes-552400589c0514e8e3f9a9f96b23d2224302e1a7.tar.gz
pardes-552400589c0514e8e3f9a9f96b23d2224302e1a7.zip
tui: a terminal's resize says a terminal's row metrics (terminalSize: .row_metrics = .{}, one cell for its tag and its body), so a terminal client's view, opened from a window's (views.open gives a new view the live one's `sized` facts, row metrics among them, and a resize with none keeps them, Core.zig 1681), wraps its tags at its own width: the user's "in some of them contents got cut" (2026-11-24), the hunt's cause 4: a 100-column terminal client of a window's session wrapped the PDF's tag at 120 characters in a 98-cell row (the window's tagline glyphs a fifth narrower than its body: layout.tagCapacity), its first row cut and its second begun past what was cut, the middle of a long tag never shown (the hunt's screens: 124 characters, the second row " Del"); TEST FIRST: tui.zig "a terminal client's view, opened from a window's, wraps a tag at its own width" (two views, 140 and 100 columns, a file's pane with a 40-word tag): before, w22 to w27 missing; after, every word shown; the PDF's text cut at a narrower client's right edge is the PDF's text layer drawn line by line, unwrapped (pdf.zig paint), the same in a terminal session of that width alone; nothing on the wire changes shape (the field was there, null)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'dev')
-rw-r--r--dev/tui/tui.zig48
1 files changed, 48 insertions, 0 deletions
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig
index e2cdd2fa..91b25b7a 100644
--- a/dev/tui/tui.zig
+++ b/dev/tui/tui.zig
@@ -442,6 +442,11 @@ fn terminalSize(cols: u16, rows: u16, pixel_w: u16, pixel_h: u16) @FieldType(par
.w = @intCast(terminalCellPixels(pixel_w, cols, 8)),
.h = @intCast(terminalCellPixels(pixel_h, rows, 16)),
},
+ // A terminal's tag and body are one cell: its own row metrics, said,
+ // never those of the view its client's was opened from (a window's
+ // tagline is narrower than its body: a tag wrapped at a fifth more
+ // than its row held, the middle of a long tag never shown).
+ .row_metrics = .{},
};
}
@@ -3289,3 +3294,46 @@ test "the tty draws a glide at whole rows: once a flick or a spin slows, its ste
try std.testing.expectEqual(row, (shown.cursor orelse return error.NoCursor).y);
}
}
+test "a terminal client's view, opened from a window's, wraps a tag at its own width: a terminal's resize says a terminal's row metrics" {
+ const gpa = std.testing.allocator;
+ const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 140, .rows = 45 });
+ defer core.deinit();
+ // The session's window: its tag line's glyphs narrower than its body's,
+ // so a tag row holds more of them than it has cells.
+ core.update(.{ .resize = .{ .cols = 140, .rows = 45, .cell_pixels = .{ .w = 16, .h = 33 }, .row_metrics = .{ .body_w = 16, .body_h = 33, .tagline_w = 13, .tagline_h = 26 } } });
+ const pane = try core.setTestFile("text\n");
+ var words: [40][3]u8 = undefined;
+ var tag: std.ArrayList(u8) = .empty;
+ defer tag.deinit(gpa);
+ for (&words, 0..) |*w, i| {
+ w.* = .{ 'w', '0' + @as(u8, @intCast(i / 10)), '0' + @as(u8, @intCast(i % 10)) };
+ try tag.appendSlice(gpa, " ");
+ try tag.appendSlice(gpa, w);
+ }
+ if (pane.tag.own) |own| gpa.free(own);
+ pane.tag.own = try gpa.dupe(u8, tag.items);
+ // A terminal's client joins: its view opened from the window's, then
+ // sized by its terminal, as the client's first inputs do.
+ const k = core.openView().?;
+ core.toView(k);
+ core.update(.{ .resize = terminalSize(100, 30, 0, 0) });
+ core.sync();
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ const s = try core.render(arena.allocator());
+ var shown: std.ArrayList(u8) = .empty;
+ defer shown.deinit(gpa);
+ for (s.regionList()) |region| {
+ if (region.kind != .tag) continue;
+ for (region.rect.y..region.rect.y + region.rect.h) |y| {
+ for (s.cells[y * s.cols ..][region.rect.x..][0..region.rect.w]) |cell| try shown.appendSlice(gpa, if (cell.len == 0) " " else cell.grapheme());
+ try shown.append(gpa, '\n');
+ }
+ }
+ // Each of its words shows: wrapped at its rows' width, none lost
+ // between a row cut short and the next.
+ for (&words) |*w| if (std.mem.indexOf(u8, shown.items, w) == null) {
+ std.debug.print("{s} is not shown in the tag:\n{s}\n", .{ w, shown.items });
+ return error.TestUnexpectedResult;
+ };
+}