aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/apprt/action.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-10 21:51:57 +0300
committerGitHub <noreply@github.com>2026-09-10 21:51:57 +0300
commit425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch)
treee52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/src/apprt/action.zig
parent90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff)
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/apprt/action.zig')
-rw-r--r--vendor/libghostty-vt/src/apprt/action.zig99
1 files changed, 79 insertions, 20 deletions
diff --git a/vendor/libghostty-vt/src/apprt/action.zig b/vendor/libghostty-vt/src/apprt/action.zig
index 4728d73c..7e902e56 100644
--- a/vendor/libghostty-vt/src/apprt/action.zig
+++ b/vendor/libghostty-vt/src/apprt/action.zig
@@ -8,6 +8,7 @@ const renderer = @import("../renderer.zig");
const terminal = @import("../terminal/main.zig");
const CoreSurface = @import("../Surface.zig");
const lib = @import("../lib/main.zig");
+const compat_testing = @import("../lib/compat/testing.zig");
/// The target for an action. This is generally the thing that had focus
/// while the action was made but the concept of "focus" is not guaranteed
@@ -195,6 +196,9 @@ pub const Action = union(Key) {
/// rendered at the next opportunity.
render_inspector,
+ /// Export the Terminal IO inspector event log.
+ export_terminal_io: ExportTerminalIO,
+
/// Show a desktop notification.
desktop_notification: DesktopNotification,
@@ -204,6 +208,9 @@ pub const Action = union(Key) {
/// Set the tab title override for the target's tab.
set_tab_title: SetTitle,
+ /// Set the window title override for the target's tab.
+ set_window_title: SetTitle,
+
/// Set the title of the target to a prompted value. It is up to
/// the apprt to prompt. The value specifies whether to prompt for the
/// surface title or the tab title.
@@ -227,7 +234,7 @@ pub const Action = union(Key) {
/// Open the Ghostty configuration. This is platform-specific about
/// what it means; it can mean opening a dedicated UI or just opening
/// a file in a text editor.
- open_config,
+ open_config: OpenConfig,
/// Called when there are no more surfaces and the app should quit
/// after the configured delay.
@@ -347,6 +354,9 @@ pub const Action = union(Key) {
/// otherwise the terminal-set title.
copy_title_to_clipboard,
+ /// Move a tab to a new window.
+ move_tab_to_new_window,
+
/// Sync with: ghostty_action_tag_e
pub const Key = enum(c_int) {
quit,
@@ -380,9 +390,11 @@ pub const Action = union(Key) {
inspector,
show_gtk_inspector,
render_inspector,
+ export_terminal_io,
desktop_notification,
set_title,
set_tab_title,
+ set_window_title,
prompt_title,
pwd,
mouse_shape,
@@ -415,6 +427,7 @@ pub const Action = union(Key) {
search_selected,
readonly,
copy_title_to_clipboard,
+ move_tab_to_new_window,
test "ghostty.h Action.Key" {
try lib.checkGhosttyHEnum(Key, "GHOSTTY_ACTION_");
@@ -424,8 +437,11 @@ pub const Action = union(Key) {
/// Sync with: ghostty_action_u
pub const CValue = cvalue: {
const key_fields = @typeInfo(Key).@"enum".fields;
- var union_fields: [key_fields.len]std.builtin.Type.UnionField = undefined;
- for (key_fields, 0..) |field, i| {
+ var names: [key_fields.len][]const u8 = undefined;
+ var types: [key_fields.len]type = undefined;
+ var attrs: [key_fields.len]std.builtin.Type.UnionField.Attributes = undefined;
+
+ for (key_fields, &names, &types, &attrs) |field, *name, *ty, *attr| {
const action = @unionInit(Action, field.name, undefined);
const Type = t: {
const Type = @TypeOf(@field(action, field.name));
@@ -434,19 +450,12 @@ pub const Action = union(Key) {
break :t Type;
};
- union_fields[i] = .{
- .name = field.name,
- .type = Type,
- .alignment = @alignOf(Type),
- };
+ name.* = field.name;
+ ty.* = Type;
+ attr.* = .{ .@"align" = @alignOf(Type) };
}
- break :cvalue @Type(.{ .@"union" = .{
- .layout = .@"extern",
- .tag_type = null,
- .fields = &union_fields,
- .decls = &.{},
- } });
+ break :cvalue @Union(.@"extern", null, &names, &types, &attrs);
};
/// Sync with: ghostty_action_s
@@ -460,7 +469,7 @@ pub const Action = union(Key) {
// At the time of writing, we don't promise ABI compatibility
// so we can change this but I want to be aware of it.
assert(@sizeOf(CValue) == switch (@sizeOf(usize)) {
- 4 => 16,
+ 4 => 24,
8 => 24,
else => unreachable,
});
@@ -615,6 +624,37 @@ pub const Inspector = enum(c_int) {
}
};
+/// Terminal IO inspector contents to export. The contents are only valid for
+/// the duration of the action callback.
+pub const ExportTerminalIO = struct {
+ contents: []const u8,
+
+ // Sync with: ghostty_action_export_terminal_io_s
+ pub const C = extern struct {
+ contents: [*]const u8,
+ len: usize,
+ };
+
+ pub fn cval(self: ExportTerminalIO) C {
+ return .{
+ .contents = self.contents.ptr,
+ .len = self.contents.len,
+ };
+ }
+
+ pub fn format(
+ value: @This(),
+ comptime _: []const u8,
+ _: std.fmt.Options,
+ writer: *std.Io.Writer,
+ ) !void {
+ try writer.print(
+ "{s}{{ contents: {d} bytes }}",
+ .{ @typeName(@This()), value.contents.len },
+ );
+ }
+};
+
pub const QuitTimer = enum(c_int) {
start,
stop,
@@ -642,10 +682,11 @@ pub const MouseVisibility = enum(c_int) {
}
};
-/// Whether to prompt for the surface title or tab title.
+/// Whether to prompt for the surface, tab, or window title.
pub const PromptTitle = enum(c_int) {
surface,
tab,
+ window,
test "ghostty.h PromptTitle" {
try lib.checkGhosttyHEnum(PromptTitle, "GHOSTTY_PROMPT_TITLE_");
@@ -713,7 +754,7 @@ pub const SetTitle = struct {
pub fn format(
value: @This(),
comptime _: []const u8,
- _: std.fmt.FormatOptions,
+ _: std.fmt.Options,
writer: *std.Io.Writer,
) !void {
try writer.print("{s}{{ {s} }}", .{ @typeName(@This()), value.title });
@@ -737,7 +778,7 @@ pub const Pwd = struct {
pub fn format(
value: @This(),
comptime _: []const u8,
- _: std.fmt.FormatOptions,
+ _: std.fmt.Options,
writer: *std.Io.Writer,
) !void {
try writer.print("{s}{{ {s} }}", .{ @typeName(@This()), value.pwd });
@@ -765,7 +806,7 @@ pub const DesktopNotification = struct {
pub fn format(
value: @This(),
comptime _: []const u8,
- _: std.fmt.FormatOptions,
+ _: std.fmt.Options,
writer: *std.Io.Writer,
) !void {
try writer.print("{s}{{ title: {s}, body: {s} }}", .{
@@ -909,6 +950,11 @@ pub const OpenUrl = struct {
/// The URL is known to contain HTML content.
html,
+ /// The URL came from an OSC 8 hyperlink. Application runtimes should
+ /// treat this as untrusted terminal output and apply a platform-specific
+ /// safe-opening policy.
+ osc8,
+
test "ghostty.h OpenUrl.Kind" {
try lib.checkGhosttyHEnum(Kind, "GHOSTTY_ACTION_OPEN_URL_KIND_");
}
@@ -1007,6 +1053,19 @@ pub const SearchSelected = struct {
}
};
+/// sync with ghostty_action_close_tab_mode_e in ghostty.h
+pub const OpenConfig = enum(c_int) {
+ /// Open the config in the OS default editor.
+ os_open,
+
+ /// Open the config in a new window using $EDITOR or $VISUAL
+ new_window,
+
+ test "ghostty.h OpenConfig" {
+ try lib.checkGhosttyHEnum(OpenConfig, "GHOSTTY_ACTION_OPEN_CONFIG_");
+ }
+};
+
test {
- _ = std.testing.refAllDeclsRecursive(@This());
+ _ = compat_testing.refAllDeclsRecursive(@This());
}