mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-01-03 03:52:38 +00:00
Rename goto_split top/bottom directions to up/down. (#3427)
Renames the top/bottom directions of `goto_split` to up/down. I have tested this on linux (nixos) but given that `goto_split` is broken on linux anyway (#2866) there's not a whole lot to test. I have no way to build on macOS so I can't verify that I've changed everything correctly for that. Closes #3237
This commit is contained in:
@@ -332,9 +332,9 @@ pub const GotoSplit = enum(c_int) {
|
||||
previous,
|
||||
next,
|
||||
|
||||
top,
|
||||
up,
|
||||
left,
|
||||
bottom,
|
||||
down,
|
||||
right,
|
||||
};
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ pub fn directionMap(self: *const Split, from: Side) DirectionMap {
|
||||
// This behavior matches the behavior of macOS at the time of writing
|
||||
// this. There is an open issue (#524) to make this depend on the
|
||||
// actual physical location of the current split.
|
||||
result.put(.top, prev.surface);
|
||||
result.put(.up, prev.surface);
|
||||
result.put(.left, prev.surface);
|
||||
}
|
||||
}
|
||||
@@ -347,7 +347,7 @@ pub fn directionMap(self: *const Split, from: Side) DirectionMap {
|
||||
if (self.directionNext(from)) |next| {
|
||||
result.put(.next, next.surface);
|
||||
if (!next.wrapped) {
|
||||
result.put(.bottom, next.surface);
|
||||
result.put(.down, next.surface);
|
||||
result.put(.right, next.surface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2247,12 +2247,12 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .up }, .mods = .{ .ctrl = true, .alt = true } },
|
||||
.{ .goto_split = .top },
|
||||
.{ .goto_split = .up },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .down }, .mods = .{ .ctrl = true, .alt = true } },
|
||||
.{ .goto_split = .bottom },
|
||||
.{ .goto_split = .down },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
@@ -2516,12 +2516,12 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .up }, .mods = .{ .super = true, .alt = true } },
|
||||
.{ .goto_split = .top },
|
||||
.{ .goto_split = .up },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
.{ .key = .{ .translated = .down }, .mods = .{ .super = true, .alt = true } },
|
||||
.{ .goto_split = .bottom },
|
||||
.{ .goto_split = .down },
|
||||
);
|
||||
try result.keybind.set.put(
|
||||
alloc,
|
||||
|
||||
@@ -478,10 +478,42 @@ pub const Action = union(enum) {
|
||||
previous,
|
||||
next,
|
||||
|
||||
top,
|
||||
up,
|
||||
left,
|
||||
bottom,
|
||||
down,
|
||||
right,
|
||||
|
||||
pub fn parse(input: []const u8) !SplitFocusDirection {
|
||||
return std.meta.stringToEnum(SplitFocusDirection, input) orelse {
|
||||
// For backwards compatibility we map "top" and "bottom" onto the enum
|
||||
// values "up" and "down"
|
||||
if (std.mem.eql(u8, input, "top")) {
|
||||
return .up;
|
||||
} else if (std.mem.eql(u8, input, "bottom")) {
|
||||
return .down;
|
||||
} else {
|
||||
return Error.InvalidFormat;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
test "parse" {
|
||||
const testing = std.testing;
|
||||
|
||||
try testing.expectEqual(.previous, try SplitFocusDirection.parse("previous"));
|
||||
try testing.expectEqual(.next, try SplitFocusDirection.parse("next"));
|
||||
|
||||
try testing.expectEqual(.up, try SplitFocusDirection.parse("up"));
|
||||
try testing.expectEqual(.left, try SplitFocusDirection.parse("left"));
|
||||
try testing.expectEqual(.down, try SplitFocusDirection.parse("down"));
|
||||
try testing.expectEqual(.right, try SplitFocusDirection.parse("right"));
|
||||
|
||||
try testing.expectEqual(.up, try SplitFocusDirection.parse("top"));
|
||||
try testing.expectEqual(.down, try SplitFocusDirection.parse("bottom"));
|
||||
|
||||
try testing.expectError(error.InvalidFormat, SplitFocusDirection.parse(""));
|
||||
try testing.expectError(error.InvalidFormat, SplitFocusDirection.parse("green"));
|
||||
}
|
||||
};
|
||||
|
||||
pub const SplitResizeDirection = enum {
|
||||
@@ -524,7 +556,16 @@ pub const Action = union(enum) {
|
||||
comptime field: std.builtin.Type.UnionField,
|
||||
param: []const u8,
|
||||
) !field.type {
|
||||
return switch (@typeInfo(field.type)) {
|
||||
const field_info = @typeInfo(field.type);
|
||||
|
||||
// Fields can provide a custom "parse" function
|
||||
if (field_info == .Struct or field_info == .Union or field_info == .Enum) {
|
||||
if (@hasDecl(field.type, "parse") and @typeInfo(@TypeOf(field.type.parse)) == .Fn) {
|
||||
return field.type.parse(param);
|
||||
}
|
||||
}
|
||||
|
||||
return switch (field_info) {
|
||||
.Enum => try parseEnum(field.type, param),
|
||||
.Int => try parseInt(field.type, param),
|
||||
.Float => try parseFloat(field.type, param),
|
||||
|
||||
Reference in New Issue
Block a user