mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
input: rename "unmapped" to "physical"
This commit is contained in:
@ -1020,7 +1020,7 @@ pub fn keyCallback(
|
|||||||
self: *Surface,
|
self: *Surface,
|
||||||
action: input.Action,
|
action: input.Action,
|
||||||
key: input.Key,
|
key: input.Key,
|
||||||
unmapped_key: input.Key,
|
physical_key: input.Key,
|
||||||
mods: input.Mods,
|
mods: input.Mods,
|
||||||
) !bool {
|
) !bool {
|
||||||
const tracy = trace(@src());
|
const tracy = trace(@src());
|
||||||
@ -1054,8 +1054,8 @@ pub fn keyCallback(
|
|||||||
const set = self.config.keybind.set;
|
const set = self.config.keybind.set;
|
||||||
if (set.get(trigger)) |v| break :action v;
|
if (set.get(trigger)) |v| break :action v;
|
||||||
|
|
||||||
trigger.key = unmapped_key;
|
trigger.key = physical_key;
|
||||||
trigger.unmapped = true;
|
trigger.physical = true;
|
||||||
if (set.get(trigger)) |v| break :action v;
|
if (set.get(trigger)) |v| break :action v;
|
||||||
|
|
||||||
break :action null;
|
break :action null;
|
||||||
|
@ -53,11 +53,11 @@ pub fn parse(input: []const u8) !Binding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the key starts with "unmapped" then this is an unmapped key.
|
// If the key starts with "physical" then this is an physical key.
|
||||||
const unmapped_prefix = "unmapped:";
|
const physical = "physical:";
|
||||||
const key_part = if (std.mem.startsWith(u8, part, unmapped_prefix)) key_part: {
|
const key_part = if (std.mem.startsWith(u8, part, physical)) key_part: {
|
||||||
result.unmapped = true;
|
result.physical = true;
|
||||||
break :key_part part[unmapped_prefix.len..];
|
break :key_part part[physical.len..];
|
||||||
} else part;
|
} else part;
|
||||||
|
|
||||||
// Check if its a key
|
// Check if its a key
|
||||||
@ -286,18 +286,18 @@ pub const Trigger = struct {
|
|||||||
/// The key modifiers that must be active for this to match.
|
/// The key modifiers that must be active for this to match.
|
||||||
mods: key.Mods = .{},
|
mods: key.Mods = .{},
|
||||||
|
|
||||||
/// key is the "unmapped" version. This is the same as mapped for
|
/// key is the "physical" version. This is the same as mapped for
|
||||||
/// standard US keyboard layouts. For non-US keyboard layouts, this
|
/// standard US keyboard layouts. For non-US keyboard layouts, this
|
||||||
/// is used to bind to a physical key location rather than a translated
|
/// is used to bind to a physical key location rather than a translated
|
||||||
/// key.
|
/// key.
|
||||||
unmapped: bool = false,
|
physical: bool = false,
|
||||||
|
|
||||||
/// Returns a hash code that can be used to uniquely identify this trigger.
|
/// Returns a hash code that can be used to uniquely identify this trigger.
|
||||||
pub fn hash(self: Binding) u64 {
|
pub fn hash(self: Binding) u64 {
|
||||||
var hasher = std.hash.Wyhash.init(0);
|
var hasher = std.hash.Wyhash.init(0);
|
||||||
std.hash.autoHash(&hasher, self.key);
|
std.hash.autoHash(&hasher, self.key);
|
||||||
std.hash.autoHash(&hasher, self.mods);
|
std.hash.autoHash(&hasher, self.mods);
|
||||||
std.hash.autoHash(&hasher, self.unmapped);
|
std.hash.autoHash(&hasher, self.physical);
|
||||||
return hasher.final();
|
return hasher.final();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -382,15 +382,15 @@ test "parse: triggers" {
|
|||||||
.action = .{ .ignore = {} },
|
.action = .{ .ignore = {} },
|
||||||
}, try parse("a+shift=ignore"));
|
}, try parse("a+shift=ignore"));
|
||||||
|
|
||||||
// unmapped keys
|
// physical keys
|
||||||
try testing.expectEqual(Binding{
|
try testing.expectEqual(Binding{
|
||||||
.trigger = .{
|
.trigger = .{
|
||||||
.mods = .{ .shift = true },
|
.mods = .{ .shift = true },
|
||||||
.key = .a,
|
.key = .a,
|
||||||
.unmapped = true,
|
.physical = true,
|
||||||
},
|
},
|
||||||
.action = .{ .ignore = {} },
|
.action = .{ .ignore = {} },
|
||||||
}, try parse("shift+unmapped:a=ignore"));
|
}, try parse("shift+physical:a=ignore"));
|
||||||
|
|
||||||
// invalid key
|
// invalid key
|
||||||
try testing.expectError(Error.InvalidFormat, parse("foo=ignore"));
|
try testing.expectError(Error.InvalidFormat, parse("foo=ignore"));
|
||||||
|
Reference in New Issue
Block a user