1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 13:21:38 +03:00

launcher: tidy up key/mod display impl to make it look nicer

Make things a little more compact and display friendly

refs: #1485
This commit is contained in:
Wez Furlong 2022-01-03 23:38:36 -07:00
parent 05ec80d945
commit 9919745d4e
2 changed files with 18 additions and 2 deletions

View File

@ -328,7 +328,12 @@ pub fn launcher(
continue;
}
key_entries.push(Entry {
label: format!("{:?} ({:?} {:?})", assignment, keycode, mods),
label: format!(
"{:?} ({} {})",
assignment,
mods.to_string(),
keycode.to_string()
),
kind: EntryKind::KeyAssignment(assignment),
});
}

View File

@ -301,7 +301,8 @@ impl ToString for KeyCode {
fn to_string(&self) -> String {
match self {
Self::RawCode(n) => format!("raw:{}", n),
Self::Char(c) => c.to_string(),
Self::Char(c) => format!("mapped:{}", c),
Self::Physical(phys) => format!("{}", phys.to_string()),
Self::Composed(s) => s.to_string(),
Self::Numpad(n) => format!("Numpad{}", n),
Self::Function(n) => format!("F{}", n),
@ -767,6 +768,16 @@ impl TryFrom<&str> for PhysKeyCode {
}
}
impl ToString for PhysKeyCode {
fn to_string(&self) -> String {
if let Some(s) = INV_PHYSKEYCODE_MAP.get(self) {
s.to_string()
} else {
format!("{:?}", self)
}
}
}
bitflags! {
#[derive(Default)]
pub struct MouseButtons: u8 {