mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
core: add resize_split binding with default keys
On macOS, use Cmd+Ctrl+Arrow keys as default bindings for resizing by 10 points in the given direction.
This commit is contained in:
@ -2426,6 +2426,14 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||||||
} else log.warn("runtime doesn't implement gotoSplit", .{});
|
} else log.warn("runtime doesn't implement gotoSplit", .{});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.resize_split => |param| {
|
||||||
|
if (@hasDecl(apprt.Surface, "resizeSplit")) {
|
||||||
|
const direction = param[0];
|
||||||
|
const amount = param[1];
|
||||||
|
self.rt_surface.resizeSplit(direction, amount);
|
||||||
|
} else log.warn("runtime doesn't implement resizeSplit", .{});
|
||||||
|
},
|
||||||
|
|
||||||
.toggle_split_zoom => {
|
.toggle_split_zoom => {
|
||||||
if (@hasDecl(apprt.Surface, "toggleSplitZoom")) {
|
if (@hasDecl(apprt.Surface, "toggleSplitZoom")) {
|
||||||
self.rt_surface.toggleSplitZoom();
|
self.rt_surface.toggleSplitZoom();
|
||||||
|
@ -956,6 +956,26 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
|||||||
.{ .key = .right, .mods = .{ .super = true, .alt = true } },
|
.{ .key = .right, .mods = .{ .super = true, .alt = true } },
|
||||||
.{ .goto_split = .right },
|
.{ .goto_split = .right },
|
||||||
);
|
);
|
||||||
|
try result.keybind.set.put(
|
||||||
|
alloc,
|
||||||
|
.{ .key = .up, .mods = .{ .super = true, .ctrl = true } },
|
||||||
|
.{ .resize_split = .{ .up, 10 } },
|
||||||
|
);
|
||||||
|
try result.keybind.set.put(
|
||||||
|
alloc,
|
||||||
|
.{ .key = .down, .mods = .{ .super = true, .ctrl = true } },
|
||||||
|
.{ .resize_split = .{ .down, 10 } },
|
||||||
|
);
|
||||||
|
try result.keybind.set.put(
|
||||||
|
alloc,
|
||||||
|
.{ .key = .left, .mods = .{ .super = true, .ctrl = true } },
|
||||||
|
.{ .resize_split = .{ .left, 10 } },
|
||||||
|
);
|
||||||
|
try result.keybind.set.put(
|
||||||
|
alloc,
|
||||||
|
.{ .key = .right, .mods = .{ .super = true, .ctrl = true } },
|
||||||
|
.{ .resize_split = .{ .right, 10 } },
|
||||||
|
);
|
||||||
|
|
||||||
// Inspector, matching Chromium
|
// Inspector, matching Chromium
|
||||||
try result.keybind.set.put(
|
try result.keybind.set.put(
|
||||||
|
@ -11,6 +11,7 @@ pub const KeyEncoder = @import("input/KeyEncoder.zig");
|
|||||||
pub const InspectorMode = Binding.Action.InspectorMode;
|
pub const InspectorMode = Binding.Action.InspectorMode;
|
||||||
pub const SplitDirection = Binding.Action.SplitDirection;
|
pub const SplitDirection = Binding.Action.SplitDirection;
|
||||||
pub const SplitFocusDirection = Binding.Action.SplitFocusDirection;
|
pub const SplitFocusDirection = Binding.Action.SplitFocusDirection;
|
||||||
|
pub const SplitResizeDirection = Binding.Action.SplitResizeDirection;
|
||||||
|
|
||||||
// Keymap is only available on macOS right now. We could implement it
|
// Keymap is only available on macOS right now. We could implement it
|
||||||
// in theory for XKB too on Linux but we don't need it right now.
|
// in theory for XKB too on Linux but we don't need it right now.
|
||||||
|
@ -179,6 +179,10 @@ pub const Action = union(enum) {
|
|||||||
/// zoom/unzoom the current split.
|
/// zoom/unzoom the current split.
|
||||||
toggle_split_zoom: void,
|
toggle_split_zoom: void,
|
||||||
|
|
||||||
|
/// Resize the current split by moving the split divider in the given
|
||||||
|
/// direction
|
||||||
|
resize_split: SplitResizeParameter,
|
||||||
|
|
||||||
/// Show, hide, or toggle the terminal inspector for the currently
|
/// Show, hide, or toggle the terminal inspector for the currently
|
||||||
/// focused terminal.
|
/// focused terminal.
|
||||||
inspector: InspectorMode,
|
inspector: InspectorMode,
|
||||||
@ -227,6 +231,19 @@ pub const Action = union(enum) {
|
|||||||
right,
|
right,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Extern because it is used in the embedded runtime ABI.
|
||||||
|
pub const SplitResizeDirection = enum(c_int) {
|
||||||
|
up,
|
||||||
|
down,
|
||||||
|
left,
|
||||||
|
right,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const SplitResizeParameter = struct {
|
||||||
|
SplitResizeDirection,
|
||||||
|
u16,
|
||||||
|
};
|
||||||
|
|
||||||
// Extern because it is used in the embedded runtime ABI.
|
// Extern because it is used in the embedded runtime ABI.
|
||||||
pub const InspectorMode = enum(c_int) {
|
pub const InspectorMode = enum(c_int) {
|
||||||
toggle,
|
toggle,
|
||||||
|
Reference in New Issue
Block a user