mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 17:26:09 +03:00
cli/gtk: move IPC/sendIPC to App/performIpc
This commit is contained in:
@ -51,7 +51,6 @@ pub const runtime = switch (build_config.artifact) {
|
|||||||
|
|
||||||
pub const App = runtime.App;
|
pub const App = runtime.App;
|
||||||
pub const Surface = runtime.Surface;
|
pub const Surface = runtime.Surface;
|
||||||
pub const IPC = runtime.IPC;
|
|
||||||
|
|
||||||
/// Runtime is the runtime to use for Ghostty. All runtimes do not provide
|
/// Runtime is the runtime to use for Ghostty. All runtimes do not provide
|
||||||
/// equivalent feature sets.
|
/// equivalent feature sets.
|
||||||
|
@ -319,6 +319,23 @@ pub const App = struct {
|
|||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send the given IPC to a running Ghostty. Returns `true` if the action was
|
||||||
|
/// able to be performed, `false` otherwise.
|
||||||
|
///
|
||||||
|
/// Note that this is a static function. Since this is called from a CLI app (or
|
||||||
|
/// some other process that is not Ghostty) there is no full-featured apprt App
|
||||||
|
/// to use.
|
||||||
|
pub fn performIpc(
|
||||||
|
_: Allocator,
|
||||||
|
_: apprt.ipc.Target,
|
||||||
|
comptime action: apprt.ipc.Action.Key,
|
||||||
|
_: apprt.ipc.Action.Value(action),
|
||||||
|
) (Allocator.Error || std.posix.WriteError || apprt.ipc.Errors)!bool {
|
||||||
|
switch (action) {
|
||||||
|
.new_window => return false,
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Platform-specific configuration for libghostty.
|
/// Platform-specific configuration for libghostty.
|
||||||
@ -1153,22 +1170,6 @@ pub const Inspector = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Functions for inter-process communication.
|
|
||||||
pub const IPC = struct {
|
|
||||||
/// Send the given IPC to a running Ghostty. Returns `true` if the action was
|
|
||||||
/// able to be performed, `false` otherwise.
|
|
||||||
pub fn sendIPC(
|
|
||||||
_: Allocator,
|
|
||||||
_: apprt.ipc.Target,
|
|
||||||
comptime action: apprt.ipc.Action.Key,
|
|
||||||
_: apprt.ipc.Action.Value(action),
|
|
||||||
) (Allocator.Error || std.posix.WriteError || apprt.ipc.Errors)!bool {
|
|
||||||
switch (action) {
|
|
||||||
.new_window => return false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// C API
|
// C API
|
||||||
pub const CAPI = struct {
|
pub const CAPI = struct {
|
||||||
const global = &@import("../global.zig").state;
|
const global = &@import("../global.zig").state;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
pub const App = @import("gtk/App.zig");
|
pub const App = @import("gtk/App.zig");
|
||||||
pub const Surface = @import("gtk/Surface.zig");
|
pub const Surface = @import("gtk/Surface.zig");
|
||||||
pub const resourcesDir = @import("gtk/flatpak.zig").resourcesDir;
|
pub const resourcesDir = @import("gtk/flatpak.zig").resourcesDir;
|
||||||
pub const IPC = @import("gtk/IPC.zig");
|
|
||||||
|
|
||||||
test {
|
test {
|
||||||
@import("std").testing.refAllDecls(@This());
|
@import("std").testing.refAllDecls(@This());
|
||||||
|
@ -34,6 +34,7 @@ const terminal = @import("../../terminal/main.zig");
|
|||||||
const Config = configpkg.Config;
|
const Config = configpkg.Config;
|
||||||
const CoreApp = @import("../../App.zig");
|
const CoreApp = @import("../../App.zig");
|
||||||
const CoreSurface = @import("../../Surface.zig");
|
const CoreSurface = @import("../../Surface.zig");
|
||||||
|
const ipc = @import("ipc.zig");
|
||||||
|
|
||||||
const cgroup = @import("cgroup.zig");
|
const cgroup = @import("cgroup.zig");
|
||||||
const Surface = @import("Surface.zig");
|
const Surface = @import("Surface.zig");
|
||||||
@ -547,6 +548,23 @@ pub fn performAction(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send the given IPC to a running Ghostty. Returns `true` if the action was
|
||||||
|
/// able to be performed, `false` otherwise.
|
||||||
|
///
|
||||||
|
/// Note that this is a static function. Since this is called from a CLI app (or
|
||||||
|
/// some other process that is not Ghostty) there is no full-featured apprt App
|
||||||
|
/// to use.
|
||||||
|
pub fn performIpc(
|
||||||
|
alloc: Allocator,
|
||||||
|
target: apprt.ipc.Target,
|
||||||
|
comptime action: apprt.ipc.Action.Key,
|
||||||
|
value: apprt.ipc.Action.Value(action),
|
||||||
|
) (Allocator.Error || std.posix.WriteError || apprt.ipc.Errors)!bool {
|
||||||
|
switch (action) {
|
||||||
|
.new_window => return try ipc.openNewWindow(alloc, target, value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn newTab(_: *App, target: apprt.Target) !void {
|
fn newTab(_: *App, target: apprt.Target) !void {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
.app => {},
|
.app => {},
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
//! Functions for inter-process communication.
|
|
||||||
const IPC = @This();
|
|
||||||
|
|
||||||
const std = @import("std");
|
|
||||||
const Allocator = std.mem.Allocator;
|
|
||||||
|
|
||||||
const apprt = @import("../../apprt.zig");
|
|
||||||
|
|
||||||
pub const openNewWindow = @import("ipc/new_window.zig").openNewWindow;
|
|
||||||
|
|
||||||
/// Send the given IPC to a running Ghostty. Returns `true` if the action was
|
|
||||||
/// able to be performed, `false` otherwise.
|
|
||||||
pub fn sendIPC(
|
|
||||||
alloc: Allocator,
|
|
||||||
target: apprt.ipc.Target,
|
|
||||||
comptime action: apprt.ipc.Action.Key,
|
|
||||||
value: apprt.ipc.Action.Value(action),
|
|
||||||
) (Allocator.Error || std.posix.WriteError || apprt.ipc.Errors)!bool {
|
|
||||||
switch (action) {
|
|
||||||
.new_window => return try openNewWindow(alloc, target, value),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
_ = openNewWindow;
|
|
||||||
}
|
|
1
src/apprt/gtk/ipc.zig
Normal file
1
src/apprt/gtk/ipc.zig
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub const openNewWindow = @import("ipc/new_window.zig").openNewWindow;
|
@ -5,12 +5,9 @@ const internal_os = @import("../os/main.zig");
|
|||||||
const apprt = @import("../apprt.zig");
|
const apprt = @import("../apprt.zig");
|
||||||
pub const resourcesDir = internal_os.resourcesDir;
|
pub const resourcesDir = internal_os.resourcesDir;
|
||||||
|
|
||||||
pub const App = struct {};
|
pub const App = struct {
|
||||||
pub const Surface = struct {};
|
|
||||||
/// Functions for inter-process communication.
|
|
||||||
pub const IPC = struct {
|
|
||||||
/// Always return false as there is no apprt to communicate with.
|
/// Always return false as there is no apprt to communicate with.
|
||||||
pub fn sendIPC(
|
pub fn performIpc(
|
||||||
_: Allocator,
|
_: Allocator,
|
||||||
_: apprt.ipc.Target,
|
_: apprt.ipc.Target,
|
||||||
comptime action: apprt.ipc.Action.Key,
|
comptime action: apprt.ipc.Action.Key,
|
||||||
@ -19,3 +16,4 @@ pub const IPC = struct {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
pub const Surface = struct {};
|
||||||
|
@ -147,7 +147,7 @@ fn runArgs(alloc_gpa: Allocator, argsIter: anytype) !u8 {
|
|||||||
defer arena.deinit();
|
defer arena.deinit();
|
||||||
const alloc = arena.allocator();
|
const alloc = arena.allocator();
|
||||||
|
|
||||||
if (apprt.IPC.sendIPC(
|
if (apprt.App.performIpc(
|
||||||
alloc,
|
alloc,
|
||||||
if (opts.class) |class| .{ .class = class } else .detect,
|
if (opts.class) |class| .{ .class = class } else .detect,
|
||||||
.new_window,
|
.new_window,
|
||||||
|
Reference in New Issue
Block a user