mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
split: add auto
as split option
Add an `auto` split direction which splits along the larger direction.
This commit is contained in:
@ -3195,7 +3195,17 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||||||
|
|
||||||
.new_split => |direction| {
|
.new_split => |direction| {
|
||||||
if (@hasDecl(apprt.Surface, "newSplit")) {
|
if (@hasDecl(apprt.Surface, "newSplit")) {
|
||||||
try self.rt_surface.newSplit(direction);
|
const resolved_direction: input.SplitDirection = switch (direction) {
|
||||||
|
.right => .right,
|
||||||
|
.down => .down,
|
||||||
|
.auto => auto: {
|
||||||
|
const size = self.screen_size;
|
||||||
|
if (size.width > size.height) {
|
||||||
|
break :auto .right;
|
||||||
|
} else break :auto .down;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
try self.rt_surface.newSplit(resolved_direction);
|
||||||
} else log.warn("runtime doesn't implement newSplit", .{});
|
} else log.warn("runtime doesn't implement newSplit", .{});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -10,10 +10,16 @@ pub const Binding = @import("input/Binding.zig");
|
|||||||
pub const Link = @import("input/Link.zig");
|
pub const Link = @import("input/Link.zig");
|
||||||
pub const KeyEncoder = @import("input/KeyEncoder.zig");
|
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 SplitFocusDirection = Binding.Action.SplitFocusDirection;
|
pub const SplitFocusDirection = Binding.Action.SplitFocusDirection;
|
||||||
pub const SplitResizeDirection = Binding.Action.SplitResizeDirection;
|
pub const SplitResizeDirection = Binding.Action.SplitResizeDirection;
|
||||||
|
|
||||||
|
// This is made extern (c_int) to make interop easier with our embedded
|
||||||
|
// runtime. The small size cost doesn't make a difference in our union.
|
||||||
|
pub const SplitDirection = enum(c_int) {
|
||||||
|
right,
|
||||||
|
down,
|
||||||
|
};
|
||||||
|
|
||||||
// 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.
|
||||||
pub const Keymap = switch (builtin.os.tag) {
|
pub const Keymap = switch (builtin.os.tag) {
|
||||||
|
@ -256,11 +256,11 @@ pub const Action = union(enum) {
|
|||||||
application: []const u8,
|
application: []const u8,
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is made extern (c_int) to make interop easier with our embedded
|
pub const SplitDirection = enum {
|
||||||
// runtime. The small size cost doesn't make a difference in our union.
|
|
||||||
pub const SplitDirection = enum(c_int) {
|
|
||||||
right,
|
right,
|
||||||
down,
|
down,
|
||||||
|
// splits along the larger direction
|
||||||
|
auto,
|
||||||
|
|
||||||
// Note: we don't support top or left yet
|
// Note: we don't support top or left yet
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user