Add settings shortcut on MacOS

- Settings shortcut opens the config file in the default editor.

Signed-off-by: Borja Clemente <borja.clemente@gmail.com>
This commit is contained in:
Borja Clemente
2023-12-17 14:22:38 +01:00
parent 5eea79ad0d
commit 646e3c365c
10 changed files with 104 additions and 2 deletions

View File

@@ -47,6 +47,9 @@ pub const App = struct {
/// called.
reload_config: *const fn (AppUD) callconv(.C) ?*const Config,
/// Open the configuration file.
open_config: *const fn (AppUD) callconv(.C) void,
/// Called to set the title of the window.
set_title: *const fn (SurfaceUD, [*]const u8) callconv(.C) void,
@@ -160,6 +163,10 @@ pub const App = struct {
}
}
pub fn openConfig(self: *App) !void {
try Config.edit(self.core_app.alloc);
}
pub fn reloadConfig(self: *App) !?*const Config {
// Reload
if (self.opts.reload_config(self.opts.userdata)) |new| {
@@ -1285,6 +1292,14 @@ pub const CAPI = struct {
};
}
/// Open the configuration.
export fn ghostty_app_open_config(v: *App) void {
_ = v.core_app.openConfig(v) catch |err| {
log.err("error reloading config err={}", .{err});
return;
};
}
/// Reload the configuration.
export fn ghostty_app_reload_config(v: *App) void {
_ = v.core_app.reloadConfig(v) catch |err| {