Fix display of +
between modifiers on linux and windows (#24173)
Regressions in #24024: * `+` was no longer included between modifiers and key * Multi-character keys like "control" were displayed all lowercase, whereas before they were all uppercase like "CONTROL". Now they are capitalized, so "Control". * Brings back icon for tab key. Release Notes: - N/A
This commit is contained in:
parent
9a22ef2fd5
commit
29e559d60c
1 changed files with 14 additions and 28 deletions
|
@ -97,15 +97,7 @@ pub fn render_key(
|
||||||
let key_icon = icon_for_key(keystroke, platform_style);
|
let key_icon = icon_for_key(keystroke, platform_style);
|
||||||
match key_icon {
|
match key_icon {
|
||||||
Some(icon) => KeyIcon::new(icon, color).into_any_element(),
|
Some(icon) => KeyIcon::new(icon, color).into_any_element(),
|
||||||
None => Key::new(
|
None => Key::new(capitalize(&keystroke.key), color).into_any_element(),
|
||||||
if keystroke.key.len() > 1 {
|
|
||||||
keystroke.key.clone()
|
|
||||||
} else {
|
|
||||||
keystroke.key.to_uppercase()
|
|
||||||
},
|
|
||||||
color,
|
|
||||||
)
|
|
||||||
.into_any_element(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +111,7 @@ fn icon_for_key(keystroke: &Keystroke, platform_style: PlatformStyle) -> Option<
|
||||||
"delete" => Some(IconName::Delete),
|
"delete" => Some(IconName::Delete),
|
||||||
"return" => Some(IconName::Return),
|
"return" => Some(IconName::Return),
|
||||||
"enter" => Some(IconName::Return),
|
"enter" => Some(IconName::Return),
|
||||||
// "tab" => Some(IconName::Tab),
|
"tab" => Some(IconName::Tab),
|
||||||
"space" => Some(IconName::Space),
|
"space" => Some(IconName::Space),
|
||||||
"escape" => Some(IconName::Escape),
|
"escape" => Some(IconName::Escape),
|
||||||
"pagedown" => Some(IconName::PageDown),
|
"pagedown" => Some(IconName::PageDown),
|
||||||
|
@ -192,18 +184,12 @@ pub fn render_modifiers(
|
||||||
.flat_map(move |modifier| {
|
.flat_map(move |modifier| {
|
||||||
if modifier.enabled {
|
if modifier.enabled {
|
||||||
match platform_style {
|
match platform_style {
|
||||||
PlatformStyle::Mac => Some(modifier.mac),
|
PlatformStyle::Mac => vec![modifier.mac],
|
||||||
PlatformStyle::Linux => Some(modifier.linux)
|
PlatformStyle::Linux => vec![modifier.linux, KeyOrIcon::Key("+")],
|
||||||
.into_iter()
|
PlatformStyle::Windows => vec![modifier.windows, KeyOrIcon::Key("+")],
|
||||||
.chain(Some(KeyOrIcon::Key("+")))
|
|
||||||
.next(),
|
|
||||||
PlatformStyle::Windows => Some(modifier.windows)
|
|
||||||
.into_iter()
|
|
||||||
.chain(Some(KeyOrIcon::Key("+")))
|
|
||||||
.next(),
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
vec![]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(move |key_or_icon| match key_or_icon {
|
.map(move |key_or_icon| match key_or_icon {
|
||||||
|
@ -359,14 +345,6 @@ pub fn text_for_keystroke(keystroke: &Keystroke, platform_style: PlatformStyle)
|
||||||
text.push(delimiter);
|
text.push(delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn capitalize(str: &str) -> String {
|
|
||||||
let mut chars = str.chars();
|
|
||||||
match chars.next() {
|
|
||||||
None => String::new(),
|
|
||||||
Some(first_char) => first_char.to_uppercase().collect::<String>() + chars.as_str(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let key = match keystroke.key.as_str() {
|
let key = match keystroke.key.as_str() {
|
||||||
"pageup" => "PageUp",
|
"pageup" => "PageUp",
|
||||||
"pagedown" => "PageDown",
|
"pagedown" => "PageDown",
|
||||||
|
@ -378,6 +356,14 @@ pub fn text_for_keystroke(keystroke: &Keystroke, platform_style: PlatformStyle)
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn capitalize(str: &str) -> String {
|
||||||
|
let mut chars = str.chars();
|
||||||
|
match chars.next() {
|
||||||
|
None => String::new(),
|
||||||
|
Some(first_char) => first_char.to_uppercase().collect::<String>() + chars.as_str(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue