summaryrefslogtreecommitdiff
path: root/term.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-06-30 13:00:23 -0300
committerGabriel Schneider <[email protected]>2026-06-30 15:32:46 -0300
commita68564e9fb9fb8be6d997db5e6ad9148fb506d18 (patch)
tree0230a359962c2e5e67bc4875050afe8411142c9e /term.zig
parent651af1db938bcbaa039d14b65ff6bc184a3d91b4 (diff)
downloadpardes-a68564e9fb9fb8be6d997db5e6ad9148fb506d18.tar.gz
pardes-a68564e9fb9fb8be6d997db5e6ad9148fb506d18.zip
images? lol
Diffstat (limited to 'term.zig')
-rw-r--r--term.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/term.zig b/term.zig
index 6f43f586..6989eb79 100644
--- a/term.zig
+++ b/term.zig
@@ -1,5 +1,6 @@
const std = @import("std");
const ghostty_vt = @import("ghostty-vt");
+const image_mod = @import("image.zig");
/// One text selection (block-shaped), in pane-local coords; the row carries the
/// scrollback offset. .none == nothing selected.
@@ -69,6 +70,16 @@ reader: std.Io.Future(anyerror!void),
/// selection, char-mode editing — is shared. pty.handle is -1, reader is a no-op.
file: ?File = null,
+/// When set, this pane displays an image (kitty graphics) instead of text. Like a
+/// file pane it has no pty/reader (handle -1) and a stub emulator; the render loop
+/// transmits + draws it. See image.zig. Mutually exclusive with `file`.
+image: ?image_mod.View = null,
+
+/// A freshly forked terminal greets with `ls` once it has its real geometry. Set
+/// at fork; the resize loop fires the `ls` after sizing the pty, so the listing
+/// wraps to the right width (sending it at fork time uses the wrong, full size).
+greet: bool = false,
+
/// current emulator grid size; we only push a resize when it actually changes.
cols: u16,
rows: u16,
@@ -101,10 +112,17 @@ cur_off: u16 = 0,
nedits: usize = 0,
edits: [MAX_EDITS]Edit = @splat(.{}),
+/// A real shell pane (has a pty/emulator), as opposed to a file or image view.
+pub fn isTerminal(self: *const Term) bool {
+ return self.file == null and self.image == null;
+}
+
pub fn deinit(self: *Term, io: std.Io, gpa: std.mem.Allocator) void {
if (self.file) |f| {
gpa.free(f.path);
gpa.free(f.content);
+ } else if (self.image) |iv| {
+ gpa.free(iv.path);
} else {
_ = self.reader.cancel(io) catch {};
self.pty.close(io);