diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 10:49:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 68a74ec034a24c9b016497880e375f291498ae5f (patch) | |
| tree | 968a3eeec731d3ea632ab98f872074863ec6183b /src/Terminal.zig | |
| parent | 73e797e3f31eb52b0074b86cd16949c827b75670 (diff) | |
| download | pardes-68a74ec034a24c9b016497880e375f291498ae5f.tar.gz pardes-68a74ec034a24c9b016497880e375f291498ae5f.zip | |
A terminal's new directory is a rename in the log, and its ctl counts its body
The log said new N / and later del N <cwd> for a terminal, with no rename
in between, though a terminal is named by its directory. setCwd now logs
the rename once the pane has been announced. A terminal's ctl line gave
body length 0 while its body reads its history; it now counts that
history (without keeping a copy).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/Terminal.zig')
| -rw-r--r-- | src/Terminal.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Terminal.zig b/src/Terminal.zig index 16d5af26..0bec3ce8 100644 --- a/src/Terminal.zig +++ b/src/Terminal.zig @@ -368,6 +368,22 @@ pub fn screenTextAlloc(pane: *Pane, gpa: std.mem.Allocator) ![]const u8 { return state.vt.screens.active.dumpStringAlloc(gpa, .{ .screen = .{} }); } +/// How long `screenTextAlloc` would be, counted without keeping it: the +/// length a terminal's body reads as, which its ctl line reports. +pub fn screenTextLen(pane: *Pane) usize { + if (comptime !enabled) return 0; + const state = pane.terminal orelse return 0; + const screen = state.vt.screens.active; + var buf: [256]u8 = undefined; + var counting: std.Io.Writer.Discarding = .init(&buf); + screen.dumpString(&counting.writer, .{ + .tl = screen.pages.getTopLeft(.screen), + .br = screen.pages.getBottomRight(.screen) orelse return 0, + .unwrap = false, + }) catch return 0; + return @intCast(counting.fullCount()); +} + /// Release the emulator's heap. The Pane allocation itself is the core's. pub fn deinitEmulator(pane: *Pane, gpa: std.mem.Allocator) void { if (comptime !enabled) return; |
