aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/terminal/c/terminal.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-19 14:47:18 +0300
committerGitHub <noreply@github.com>2026-09-19 14:47:18 +0300
commitcc7c696cd0772e466da403eb4e3f00f4e8d8ae1e (patch)
treed8325f7f2fb1ac53613ae56e8215042e6d497dd9 /vendor/libghostty-vt/src/terminal/c/terminal.zig
parent3f2a6e743f67bc947cfa06be25df106d00b9ee11 (diff)
feat: add configurable pane screen and scrollback clearing (#4383)
Diffstat (limited to 'vendor/libghostty-vt/src/terminal/c/terminal.zig')
-rw-r--r--vendor/libghostty-vt/src/terminal/c/terminal.zig34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/terminal/c/terminal.zig b/vendor/libghostty-vt/src/terminal/c/terminal.zig
index 73097573..91bbe310 100644
--- a/vendor/libghostty-vt/src/terminal/c/terminal.zig
+++ b/vendor/libghostty-vt/src/terminal/c/terminal.zig
@@ -1504,6 +1504,40 @@ pub fn reset(terminal_: Terminal) callconv(lib.calling_conv) void {
t.fullReset();
}
+/// Clear output without feeding synthetic bytes into the child's VT stream.
+pub fn clearScreen(terminal_: Terminal) callconv(lib.calling_conv) bool {
+ const t: *ZigTerminal = (terminal_ orelse return false).terminal;
+ if (t.screens.active_key == .alternate) return false;
+ const screen = t.screens.active;
+
+ var first = screen.cursor.y;
+ while (first > 0) {
+ const pin = screen.pages.pin(.{ .active = .{ .y = first } }).?;
+ if (!pin.rowAndCell().row.wrap_continuation) break;
+ first -= 1;
+ }
+ var last = screen.cursor.y;
+ while (last + 1 < t.rows) {
+ const pin = screen.pages.pin(.{ .active = .{ .y = last } }).?;
+ if (!pin.rowAndCell().row.wrap) break;
+ last += 1;
+ }
+
+ screen.clearSelection();
+ if (last + 1 < t.rows) {
+ screen.clearRows(.{ .active = .{ .y = last + 1 } }, null, false);
+ }
+ screen.eraseHistory(null);
+ if (first > 0) screen.eraseActive(first - 1);
+ screen.pages.pin(.{ .active = .{} }).?.rowAndCell().row.wrap_continuation = false;
+ screen.scroll(.active);
+ if (comptime build_options.kitty_graphics) {
+ screen.kitty_images.delete(t.io(), screen.alloc, t, .{ .all = true });
+ }
+ t.flags.dirty.clear = true;
+ return true;
+}
+
/// C: GhosttyKittyGraphics
pub const KittyGraphics = kitty_gfx_c.KittyGraphics;