diff options
| author | Mitchell Hashimoto <m@mitchellh.com> | 2025-09-21 10:06:53 -0700 |
|---|---|---|
| committer | Mitchell Hashimoto <m@mitchellh.com> | 2025-09-21 19:41:58 -0700 |
| commit | 64f26c14d3f370b026f61c8b6c53d4bb32a61b5b (patch) | |
| tree | dfd12294413c96dcebfc18206c70c6a310da5f6b /example/zig-vt/src | |
| parent | 1758f962f6af5813a8d3f24de2dafc278d00e085 (diff) | |
example/zig-vt
Diffstat (limited to 'example/zig-vt/src')
| -rw-r--r-- | example/zig-vt/src/main.zig | 26 |
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}); +} |
