macos: add pid and tty properties to AppleScript terminal and App Intents TerminalEntity (#11922)

This commit is contained in:
Lukas
2026-04-20 18:10:57 +02:00
committed by GitHub
7 changed files with 63 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ const CoreInspector = @import("../inspector/main.zig").Inspector;
const CoreSurface = @import("../Surface.zig");
const configpkg = @import("../config.zig");
const Config = configpkg.Config;
const String = @import("../main_c.zig").String;
const log = std.log.scoped(.embedded_window);
@@ -1709,6 +1710,23 @@ pub const CAPI = struct {
};
}
/// Returns the PID of the foreground process for the surface PTY.
export fn ghostty_surface_foreground_pid(surface: *Surface) u64 {
return surface.core_surface.getProcessInfo(.foreground_pid) orelse 0;
}
/// Returns the PTY name for the surface. The returned string must be
/// freed by the caller via ghostty_string_free.
export fn ghostty_surface_tty_name(surface: *Surface) String {
const tty_name = surface.core_surface.getProcessInfo(.tty_name) orelse return .empty;
const copy = surface.app.core_app.alloc.dupeZ(u8, tty_name) catch |err| {
log.err("error allocating tty name err={}", .{err});
return .empty;
};
return .fromSlice(copy);
}
/// Update the color scheme of the surface.
export fn ghostty_surface_set_color_scheme(surface: *Surface, scheme_raw: c_int) void {
const scheme = std.meta.intToEnum(apprt.ColorScheme, scheme_raw) catch {

View File

@@ -2,7 +2,7 @@ const builtin = @import("builtin");
const std = @import("std");
const inputpkg = @import("../input.zig");
const state = &@import("../global.zig").state;
const c = @import("../main_c.zig");
const String = @import("../main_c.zig").String;
const Config = @import("Config.zig");
const c_get = @import("c_get.zig");
@@ -132,7 +132,7 @@ export fn ghostty_config_get_diagnostic(self: *Config, idx: u32) Diagnostic {
return .{ .message = message.ptr };
}
export fn ghostty_config_open_path() c.String {
export fn ghostty_config_open_path() String {
const path = edit.openPath(state.alloc) catch |err| {
log.err("error opening config in editor err={}", .{err});
return .empty;