From bf7b3150e4f7cac308aff12281ae7085b8465dec Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 16 Aug 2022 23:10:05 -0700 Subject: [PATCH] Added show character palette. Need to position correctly. --- assets/keymaps/default.json | 2 ++ crates/terminal/src/connected_view.rs | 17 ++++++++++++++++- crates/terminal/src/mappings/keys.rs | 1 - 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 6f34facc42..b40a076c49 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -420,6 +420,7 @@ "enter": "terminal::Enter", "ctrl-c": "terminal::CtrlC", // Useful terminal actions: + "ctrl-cmd-space": "terminal::ShowCharacterPalette", "cmd-c": "terminal::Copy", "cmd-v": "terminal::Paste", "cmd-k": "terminal::Clear" @@ -428,6 +429,7 @@ { "context": "ModalTerminal", "bindings": { + "ctrl-cmd-space": "terminal::ShowCharacterPalette", "shift-escape": "terminal::DeployModal" } } diff --git a/crates/terminal/src/connected_view.rs b/crates/terminal/src/connected_view.rs index 6f16ac9bcd..905c27d2b9 100644 --- a/crates/terminal/src/connected_view.rs +++ b/crates/terminal/src/connected_view.rs @@ -29,7 +29,17 @@ pub struct DeployContextMenu { actions!( terminal, - [Up, Down, CtrlC, Escape, Enter, Clear, Copy, Paste,] + [ + Up, + Down, + CtrlC, + Escape, + Enter, + Clear, + Copy, + Paste, + ShowCharacterPalette + ] ); impl_internal_actions!(project_panel, [DeployContextMenu]); @@ -45,6 +55,7 @@ pub fn init(cx: &mut MutableAppContext) { cx.add_action(ConnectedView::copy); cx.add_action(ConnectedView::paste); cx.add_action(ConnectedView::clear); + cx.add_action(ConnectedView::show_character_palette); } ///A terminal view, maintains the PTY's file handles and communicates with the terminal @@ -126,6 +137,10 @@ impl ConnectedView { cx.notify(); } + fn show_character_palette(&mut self, _: &ShowCharacterPalette, cx: &mut ViewContext) { + cx.show_character_palette(); + } + fn clear(&mut self, _: &Clear, cx: &mut ViewContext) { self.terminal.update(cx, |term, _| term.clear()); cx.notify(); diff --git a/crates/terminal/src/mappings/keys.rs b/crates/terminal/src/mappings/keys.rs index e07a324998..002759d78d 100644 --- a/crates/terminal/src/mappings/keys.rs +++ b/crates/terminal/src/mappings/keys.rs @@ -53,7 +53,6 @@ pub fn to_esc_str(keystroke: &Keystroke, mode: &TermMode) -> Option { // Manual Bindings including modifiers let manual_esc_str = match (keystroke.key.as_ref(), &modifiers) { //Basic special keys - ("space", Modifiers::None) => Some(" ".to_string()), ("tab", Modifiers::None) => Some("\x09".to_string()), ("escape", Modifiers::None) => Some("\x1b".to_string()), ("enter", Modifiers::None) => Some("\x0d".to_string()),