mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
keybindings: improve sort to include key value 1,2,3,4...
This commit is contained in:
@ -185,10 +185,29 @@ pub fn lessThan(_: void, lhs: Binding, rhs: Binding) bool {
|
|||||||
if (rhs.trigger.mods.alt) count += 1;
|
if (rhs.trigger.mods.alt) count += 1;
|
||||||
break :blk count;
|
break :blk count;
|
||||||
};
|
};
|
||||||
if (lhs_count == rhs_count)
|
|
||||||
|
if (lhs_count != rhs_count)
|
||||||
|
return lhs_count > rhs_count;
|
||||||
|
|
||||||
|
if (lhs.trigger.mods.int() != rhs.trigger.mods.int())
|
||||||
return lhs.trigger.mods.int() > rhs.trigger.mods.int();
|
return lhs.trigger.mods.int() > rhs.trigger.mods.int();
|
||||||
|
|
||||||
return lhs_count > rhs_count;
|
const lhs_key: c_int = blk: {
|
||||||
|
switch (lhs.trigger.key) {
|
||||||
|
.translated => break :blk @intFromEnum(lhs.trigger.key.translated),
|
||||||
|
.physical => break :blk @intFromEnum(lhs.trigger.key.physical),
|
||||||
|
.unicode => break :blk @intCast(lhs.trigger.key.unicode),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const rhs_key: c_int = blk: {
|
||||||
|
switch (rhs.trigger.key) {
|
||||||
|
.translated => break :blk @intFromEnum(rhs.trigger.key.translated),
|
||||||
|
.physical => break :blk @intFromEnum(rhs.trigger.key.physical),
|
||||||
|
.unicode => break :blk @intCast(rhs.trigger.key.unicode),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return lhs_key < rhs_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The set of actions that a keybinding can take.
|
/// The set of actions that a keybinding can take.
|
||||||
|
Reference in New Issue
Block a user