mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
core: add zoom keybinding for splits
This commit is contained in:
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user