mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
keybindings: improve sort to include key value 1,2,3,4... (#4399)
Current sort used by `+list-keybinds` doesn't include the value of the key: ``` ctrl + shift + v paste_from_clipboard ctrl + shift + a select_all ... ctrl + shift + q quit ctrl + shift + n new_window ... alt + five goto_tab:5 alt + eight goto_tab:8 ... alt + six goto_tab:6 alt + seven goto_tab:7 ``` adding the key value improves the sort order ``` ctrl + shift + a select_all ctrl + shift + c copy_to_clipboard ... ctrl + shift + n new_window ctrl + shift + o new_split:right ctrl + shift + q quit ... alt + one goto_tab:1 alt + two goto_tab:2 alt + three goto_tab:3 ... alt + eight goto_tab:8 alt + nine last_tab alt + f4 close_window
This commit is contained in:
@ -193,10 +193,29 @@ pub fn lessThan(_: void, lhs: Binding, rhs: Binding) bool {
|
||||
if (rhs.trigger.mods.alt) count += 1;
|
||||
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_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.
|
||||
|
Reference in New Issue
Block a user