non-macos doesn't support directional bindings

This commit is contained in:
Mitchell Hashimoto
2023-08-07 14:52:20 -07:00
parent 47bed51177
commit 32eb226fa3
3 changed files with 27 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
const Binding = @This();
const std = @import("std");
const builtin = @import("builtin");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const key = @import("key.zig");

View File

@@ -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
test {
const testing = std.testing;