ui: Add Backspace/Delete icons and use them for keybindings.

This commit is contained in:
Piotr Osiewicz
2024-01-02 16:41:56 +01:00
parent f5b3e473fc
commit c6d9bc5a16
4 changed files with 19 additions and 12 deletions
+4
View File
@@ -32,6 +32,7 @@ pub enum Icon {
AtSign,
AudioOff,
AudioOn,
Backspace,
Bell,
BellOff,
BellRing,
@@ -50,6 +51,7 @@ pub enum Icon {
CopilotError,
CopilotDisabled,
Dash,
Delete,
Disconnected,
Ellipsis,
Envelope,
@@ -115,6 +117,7 @@ impl Icon {
Icon::AtSign => "icons/at-sign.svg",
Icon::AudioOff => "icons/speaker-off.svg",
Icon::AudioOn => "icons/speaker-loud.svg",
Icon::Backspace => "icons/backspace.svg",
Icon::Bell => "icons/bell.svg",
Icon::BellOff => "icons/bell-off.svg",
Icon::BellRing => "icons/bell-ring.svg",
@@ -133,6 +136,7 @@ impl Icon {
Icon::CopilotError => "icons/copilot_error.svg",
Icon::CopilotDisabled => "icons/copilot_disabled.svg",
Icon::Dash => "icons/dash.svg",
Icon::Delete => "icons/delete.svg",
Icon::Disconnected => "icons/disconnected.svg",
Icon::Ellipsis => "icons/ellipsis.svg",
Icon::Envelope => "icons/feedback.svg",
+8 -12
View File
@@ -65,19 +65,15 @@ impl KeyBinding {
}
fn icon_for_key(keystroke: &Keystroke) -> Option<Icon> {
let mut icon: Option<Icon> = None;
if keystroke.key == "left".to_string() {
icon = Some(Icon::ArrowLeft);
} else if keystroke.key == "right".to_string() {
icon = Some(Icon::ArrowRight);
} else if keystroke.key == "up".to_string() {
icon = Some(Icon::ArrowUp);
} else if keystroke.key == "down".to_string() {
icon = Some(Icon::ArrowDown);
match keystroke.key.as_str() {
"left" => Some(Icon::ArrowLeft),
"right" => Some(Icon::ArrowRight),
"up" => Some(Icon::ArrowUp),
"down" => Some(Icon::ArrowDown),
"backspace" => Some(Icon::Backspace),
"delete" => Some(Icon::Delete),
_ => None,
}
icon
}
pub fn new(key_binding: gpui::KeyBinding) -> Self {