aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/cli/toggle_quick_terminal.zig
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-01 23:05:23 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-01 23:05:51 +0300
commit5bd21b7ed468b5ff4d1a5b2ed7e211f401eb138a (patch)
tree672fa4625cca0ecb3e9376fc7f8e33d7b0e9deef /vendor/libghostty-vt/src/cli/toggle_quick_terminal.zig
parent32abb3776668ee768200019c170956f67fe33a86 (diff)
chore: update libghostty vendor
refs #276
Diffstat (limited to 'vendor/libghostty-vt/src/cli/toggle_quick_terminal.zig')
-rw-r--r--vendor/libghostty-vt/src/cli/toggle_quick_terminal.zig62
1 files changed, 62 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/cli/toggle_quick_terminal.zig b/vendor/libghostty-vt/src/cli/toggle_quick_terminal.zig
new file mode 100644
index 00000000..233700f7
--- /dev/null
+++ b/vendor/libghostty-vt/src/cli/toggle_quick_terminal.zig
@@ -0,0 +1,62 @@
+const std = @import("std");
+const Allocator = std.mem.Allocator;
+const Action = @import("../cli.zig").ghostty.Action;
+const apprt = @import("../apprt.zig");
+
+pub const Options = struct {
+ /// If set, connect to a custom instance of Ghostty.
+ class: ?[:0]const u8 = null,
+
+ pub fn deinit(self: *Options) void {
+ self.* = undefined;
+ }
+
+ /// Enables "-h" and "--help" to work.
+ pub fn help(self: Options) !void {
+ _ = self;
+ return Action.help_error;
+ }
+};
+
+/// The `+toggle-quick-terminal` command will use native platform IPC to toggle
+/// the quick terminal in a running instance of Ghostty.
+///
+/// If the `--class` flag is not set, the command will try and connect to the
+/// default running Ghostty instance. Otherwise it will contact a Ghostty
+/// instance configured with the given `class`.
+///
+/// On GTK, D-Bus activation must be properly configured. Ghostty does not need
+/// to be running, as D-Bus will handle launching a new instance if it is not
+/// already running.
+///
+/// Only supported on GTK.
+///
+/// Flags:
+///
+/// * `--class=<class>`: If set, connect to a custom instance of Ghostty.
+/// The class must be a valid GTK application ID.
+///
+/// Available since: 1.4.0
+pub fn run(alloc: Allocator) !u8 {
+ var buf: [256]u8 = undefined;
+ var stderr_writer = std.fs.File.stderr().writer(&buf);
+ const stderr = &stderr_writer.interface;
+
+ if (apprt.App.performIpc(
+ alloc,
+ .detect,
+ .toggle_quick_terminal,
+ {},
+ ) catch |err| switch (err) {
+ error.IPCFailed => {
+ return 1;
+ },
+ else => {
+ try stderr.print("Sending the IPC failed: {}\n", .{err});
+ return 1;
+ },
+ }) return 0;
+
+ try stderr.print("+toggle-quick-terminal is not supported on this platform.\n", .{});
+ return 1;
+}