summaryrefslogtreecommitdiff
path: root/example/zig-vt/src
diff options
context:
space:
mode:
authorMitchell Hashimoto <m@mitchellh.com>2025-09-21 10:06:53 -0700
committerMitchell Hashimoto <m@mitchellh.com>2025-09-21 19:41:58 -0700
commit64f26c14d3f370b026f61c8b6c53d4bb32a61b5b (patch)
treedfd12294413c96dcebfc18206c70c6a310da5f6b /example/zig-vt/src
parent1758f962f6af5813a8d3f24de2dafc278d00e085 (diff)
example/zig-vt
Diffstat (limited to 'example/zig-vt/src')
-rw-r--r--example/zig-vt/src/main.zig26
1 files changed, 26 insertions, 0 deletions
diff --git a/example/zig-vt/src/main.zig b/example/zig-vt/src/main.zig
new file mode 100644
index 000000000..f57c70087
--- /dev/null
+++ b/example/zig-vt/src/main.zig
@@ -0,0 +1,26 @@
+const std = @import("std");
+const ghostty_vt = @import("ghostty-vt");
+
+pub fn main() !void {
+ // Use a debug allocator so we get leak checking. You probably want
+ // to replace this for release builds.
+ var gpa: std.heap.DebugAllocator(.{}) = .init;
+ defer _ = gpa.deinit();
+ const alloc = gpa.allocator();
+
+ // Initialize a terminal.
+ var t: ghostty_vt.Terminal = try .init(alloc, .{
+ .cols = 6,
+ .rows = 40,
+ });
+ defer t.deinit(alloc);
+
+ // Write some text. It'll wrap because this is too long for our
+ // columns size above (6).
+ try t.printString("Hello, World!");
+
+ // Get the plain string view of the terminal screen.
+ const str = try t.plainString(alloc);
+ defer alloc.free(str);
+ std.debug.print("{s}\n", .{str});
+}