summaryrefslogtreecommitdiff
path: root/src/Terminal.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Terminal.zig')
-rw-r--r--src/Terminal.zig16
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;