mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
non-macos doesn't support directional bindings
This commit is contained in:
@ -3,6 +3,7 @@ const std = @import("std");
|
|||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||||
|
const apprt = @import("apprt.zig");
|
||||||
const inputpkg = @import("input.zig");
|
const inputpkg = @import("input.zig");
|
||||||
const terminal = @import("terminal/main.zig");
|
const terminal = @import("terminal/main.zig");
|
||||||
const internal_os = @import("os/main.zig");
|
const internal_os = @import("os/main.zig");
|
||||||
@ -1206,7 +1207,18 @@ pub const Keybinds = struct {
|
|||||||
};
|
};
|
||||||
errdefer if (copy) |v| alloc.free(v);
|
errdefer if (copy) |v| alloc.free(v);
|
||||||
|
|
||||||
const binding = try inputpkg.Binding.parse(value);
|
const binding = binding: {
|
||||||
|
var binding = try inputpkg.Binding.parse(value);
|
||||||
|
|
||||||
|
// Unless we're on native macOS, we don't allow directional
|
||||||
|
// keys, so we just remap them to "both".
|
||||||
|
if (comptime !(builtin.target.isDarwin() and apprt.runtime == apprt.embedded)) {
|
||||||
|
binding.trigger.mods = binding.trigger.mods.removeDirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
break :binding binding;
|
||||||
|
};
|
||||||
|
|
||||||
switch (binding.action) {
|
switch (binding.action) {
|
||||||
.unbind => self.set.remove(binding.trigger),
|
.unbind => self.set.remove(binding.trigger),
|
||||||
else => try self.set.put(alloc, binding.trigger, binding.action),
|
else => try self.set.put(alloc, binding.trigger, binding.action),
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
const Binding = @This();
|
const Binding = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const builtin = @import("builtin");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const key = @import("key.zig");
|
const key = @import("key.zig");
|
||||||
|
@ -33,6 +33,19 @@ pub const Mods = packed struct(Mods.Int) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Return the identical mods but with all directional configuration
|
||||||
|
/// removed and all of it set to "both".
|
||||||
|
pub fn removeDirection(self: Mods) Mods {
|
||||||
|
return Mods{
|
||||||
|
.shift = if (self.shift.pressed()) .both else .none,
|
||||||
|
.ctrl = if (self.ctrl.pressed()) .both else .none,
|
||||||
|
.alt = if (self.alt.pressed()) .both else .none,
|
||||||
|
.super = if (self.super.pressed()) .both else .none,
|
||||||
|
.caps_lock = self.caps_lock,
|
||||||
|
.num_lock = self.num_lock,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// For our own understanding
|
// For our own understanding
|
||||||
test {
|
test {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
|
Reference in New Issue
Block a user