diff --git a/include/ghostty.h b/include/ghostty.h index df042ff95..95de1339e 100644 --- a/include/ghostty.h +++ b/include/ghostty.h @@ -262,6 +262,7 @@ typedef void (*ghostty_runtime_new_tab_cb)(void *, ghostty_surface_config_s); typedef void (*ghostty_runtime_new_window_cb)(void *, ghostty_surface_config_s); typedef void (*ghostty_runtime_close_surface_cb)(void *, bool); typedef void (*ghostty_runtime_focus_split_cb)(void *, ghostty_split_focus_direction_e); +typedef void (*ghostty_runtime_zoom_split_cb)(void *); typedef void (*ghostty_runtime_goto_tab_cb)(void *, int32_t); typedef void (*ghostty_runtime_toggle_fullscreen_cb)(void *, ghostty_non_native_fullscreen_e); @@ -278,6 +279,7 @@ typedef struct { ghostty_runtime_new_window_cb new_window_cb; ghostty_runtime_close_surface_cb close_surface_cb; ghostty_runtime_focus_split_cb focus_split_cb; + ghostty_runtime_zoom_split_cb zoom_split_cb; ghostty_runtime_goto_tab_cb goto_tab_cb; ghostty_runtime_toggle_fullscreen_cb toggle_fullscreen_cb; } ghostty_runtime_config_s; diff --git a/src/Surface.zig b/src/Surface.zig index f4ed94ba8..cbbf4c5f0 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -2118,6 +2118,13 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !void } else log.warn("runtime doesn't implement gotoSplit", .{}); }, + .zoom_split => { + log.warn("ZOOM ZOOM", .{}); + if (@hasDecl(apprt.Surface, "zoomSplit")) { + self.rt_surface.zoomSplit(); + } else log.warn("runtime doesn't implement zoomSplit", .{}); + }, + .toggle_fullscreen => { if (@hasDecl(apprt.Surface, "toggleFullscreen")) { self.rt_surface.toggleFullscreen(self.config.macos_non_native_fullscreen); diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index bc6bc876e..59d934eb1 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -72,6 +72,9 @@ pub const App = struct { /// Focus the previous/next split (if any). focus_split: ?*const fn (SurfaceUD, input.SplitFocusDirection) callconv(.C) void = null, + /// Zoom the current split. + zoom_split: ?*const fn (SurfaceUD) callconv(.C) void = null, + /// Goto tab goto_tab: ?*const fn (SurfaceUD, usize) callconv(.C) void = null, @@ -270,6 +273,15 @@ pub const Surface = struct { func(self.opts.userdata, direction); } + pub fn zoomSplit(self: *const Surface) void { + const func = self.app.opts.zoom_split orelse { + log.info("runtime embedder does not support zoom split", .{}); + return; + }; + + func(self.opts.userdata); + } + pub fn getContentScale(self: *const Surface) !apprt.ContentScale { return self.content_scale; } diff --git a/src/config.zig b/src/config.zig index bd826c5d6..c73b288ca 100644 --- a/src/config.zig +++ b/src/config.zig @@ -682,6 +682,12 @@ pub const Config = struct { .{ .key = .right, .mods = .{ .super = true, .alt = true } }, .{ .goto_split = .right }, ); + + try result.keybind.set.put( + alloc, + .{ .key = .equal, .mods = .{ .super = true, .shift = true } }, + .{ .zoom_split = {} }, + ); } return result; diff --git a/src/input/Binding.zig b/src/input/Binding.zig index 143f217d9..7324748be 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -158,6 +158,9 @@ pub const Action = union(enum) { /// Focus on a split in a given direction. goto_split: SplitFocusDirection, + /// Zoom and unzoom the current split. + zoom_split: void, + /// Reload the configuration. The exact meaning depends on the app runtime /// in use but this usually involves re-reading the configuration file /// and applying any changes. Note that not all changes can be applied at