mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-01-03 20:12:42 +00:00
macos: add key binding for equalizing split sizes
This commit is contained in:
@@ -2458,6 +2458,12 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
||||
} else log.warn("runtime doesn't implement resizeSplit", .{});
|
||||
},
|
||||
|
||||
.equalize_splits => {
|
||||
if (@hasDecl(apprt.Surface, "equalizeSplits")) {
|
||||
self.rt_surface.equalizeSplits();
|
||||
} else log.warn("runtime doesn't implement equalizeSplits", .{});
|
||||
},
|
||||
|
||||
.toggle_split_zoom => {
|
||||
if (@hasDecl(apprt.Surface, "toggleSplitZoom")) {
|
||||
self.rt_surface.toggleSplitZoom();
|
||||
|
||||
@@ -95,6 +95,9 @@ pub const App = struct {
|
||||
/// Resize the current split.
|
||||
resize_split: ?*const fn (SurfaceUD, input.SplitResizeDirection, u16) callconv(.C) void = null,
|
||||
|
||||
/// Equalize all splits in the current window
|
||||
equalize_splits: ?*const fn (SurfaceUD) callconv(.C) void = null,
|
||||
|
||||
/// Zoom the current split.
|
||||
toggle_split_zoom: ?*const fn (SurfaceUD) callconv(.C) void = null,
|
||||
|
||||
@@ -396,6 +399,15 @@ pub const Surface = struct {
|
||||
func(self.opts.userdata, direction, amount);
|
||||
}
|
||||
|
||||
pub fn equalizeSplits(self: *const Surface) void {
|
||||
const func = self.app.opts.equalize_splits orelse {
|
||||
log.info("runtime embedder does not support equalize splits", .{});
|
||||
return;
|
||||
};
|
||||
|
||||
func(self.opts.userdata);
|
||||
}
|
||||
|
||||
pub fn toggleSplitZoom(self: *const Surface) void {
|
||||
const func = self.app.opts.toggle_split_zoom orelse {
|
||||
log.info("runtime embedder does not support split zoom", .{});
|
||||
@@ -1388,6 +1400,11 @@ pub const CAPI = struct {
|
||||
ptr.resizeSplit(direction, amount);
|
||||
}
|
||||
|
||||
/// Equalize the size of all splits in the current window.
|
||||
export fn ghostty_surface_split_equalize(ptr: *Surface) void {
|
||||
ptr.equalizeSplits();
|
||||
}
|
||||
|
||||
/// Invoke an action on the surface.
|
||||
export fn ghostty_surface_binding_action(
|
||||
ptr: *Surface,
|
||||
|
||||
@@ -1016,6 +1016,11 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
||||
.{ .key = .right, .mods = .{ .super = true, .ctrl = true } },
|
||||
.{ .resize_split = .{ .right, 10 } },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .equal, .mods = .{ .shift = true, .alt = true } },
|
||||
.{ .equalize_splits = {} },
|
||||
);
|
||||
|
||||
// Inspector, matching Chromium
|
||||
try result.keybind.set.put(
|
||||
|
||||
@@ -197,6 +197,9 @@ pub const Action = union(enum) {
|
||||
/// direction
|
||||
resize_split: SplitResizeParameter,
|
||||
|
||||
/// Equalize all splits in the current window
|
||||
equalize_splits: void,
|
||||
|
||||
/// Show, hide, or toggle the terminal inspector for the currently
|
||||
/// focused terminal.
|
||||
inspector: InspectorMode,
|
||||
|
||||
Reference in New Issue
Block a user