From c6d9bc5a164ae2573954434347d08ca02e681565 Mon Sep 17 00:00:00 2001
From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Date: Tue, 2 Jan 2024 14:09:35 +0100
Subject: [PATCH] ui: Add Backspace/Delete icons and use them for keybindings.
---
assets/icons/backspace.svg | 3 +++
assets/icons/delete.svg | 4 ++++
crates/ui2/src/components/icon.rs | 4 ++++
crates/ui2/src/components/keybinding.rs | 20 ++++++++------------
4 files changed, 19 insertions(+), 12 deletions(-)
create mode 100644 assets/icons/backspace.svg
create mode 100644 assets/icons/delete.svg
diff --git a/assets/icons/backspace.svg b/assets/icons/backspace.svg
new file mode 100644
index 0000000000..f7f1cf107a
--- /dev/null
+++ b/assets/icons/backspace.svg
@@ -0,0 +1,3 @@
+
diff --git a/assets/icons/delete.svg b/assets/icons/delete.svg
new file mode 100644
index 0000000000..1068cb65f2
--- /dev/null
+++ b/assets/icons/delete.svg
@@ -0,0 +1,4 @@
+
+
diff --git a/crates/ui2/src/components/icon.rs b/crates/ui2/src/components/icon.rs
index b0eed86250..0c618f2915 100644
--- a/crates/ui2/src/components/icon.rs
+++ b/crates/ui2/src/components/icon.rs
@@ -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",
diff --git a/crates/ui2/src/components/keybinding.rs b/crates/ui2/src/components/keybinding.rs
index f0de9891a7..6f63885489 100644
--- a/crates/ui2/src/components/keybinding.rs
+++ b/crates/ui2/src/components/keybinding.rs
@@ -65,19 +65,15 @@ impl KeyBinding {
}
fn icon_for_key(keystroke: &Keystroke) -> Option {
- let mut icon: Option = 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 {