From 48c253feb8f6ac8d2411a202cf668f3712dc3916 Mon Sep 17 00:00:00 2001 From: versecafe <147033096+versecafe@users.noreply.github.com> Date: Sat, 20 Jul 2024 05:20:53 -0400 Subject: [PATCH] Expand terminal menu actions (#14828) image Release Notes: - Added `Copy`, `Paste`, `Select All`, & `New Terminal` into terminal's context menu --- assets/keymaps/default-linux.json | 1 + assets/keymaps/default-macos.json | 1 + crates/terminal_view/src/terminal_view.rs | 16 +++++++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 3317a59a48..dd5f6be58f 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -606,6 +606,7 @@ "ctrl-alt-space": "terminal::ShowCharacterPalette", "shift-ctrl-c": "terminal::Copy", "ctrl-insert": "terminal::Copy", + "ctrl-a": "editor::SelectAll", "shift-ctrl-v": "terminal::Paste", "shift-insert": "terminal::Paste", "ctrl-enter": "assistant::InlineAssist", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index d366d79339..f8f3364a45 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -628,6 +628,7 @@ "ctrl-cmd-space": "terminal::ShowCharacterPalette", "cmd-c": "terminal::Copy", "cmd-v": "terminal::Paste", + "cmd-a": "editor::SelectAll", "cmd-k": "terminal::Clear", "ctrl-enter": "assistant::InlineAssist", // Some nice conveniences diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 7b16f07d0a..a525459c64 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -3,7 +3,7 @@ pub mod terminal_element; pub mod terminal_panel; use collections::HashSet; -use editor::{scroll::Autoscroll, Editor}; +use editor::{actions::SelectAll, scroll::Autoscroll, Editor}; use futures::{stream::FuturesUnordered, StreamExt}; use gpui::{ anchored, deferred, div, impl_actions, AnyElement, AppContext, DismissEvent, EventEmitter, @@ -33,8 +33,8 @@ use workspace::{ notifications::NotifyResultExt, register_serializable_item, searchable::{SearchEvent, SearchOptions, SearchableItem, SearchableItemHandle}, - CloseActiveItem, NewCenterTerminal, OpenVisible, Pane, ToolbarItemLocation, Workspace, - WorkspaceId, + CloseActiveItem, NewCenterTerminal, NewTerminal, OpenVisible, Pane, ToolbarItemLocation, + Workspace, WorkspaceId, }; use anyhow::Context; @@ -214,7 +214,13 @@ impl TerminalView { cx: &mut ViewContext, ) { let context_menu = ContextMenu::build(cx, |menu, _| { - menu.action("Clear", Box::new(Clear)) + menu.action("New Terminal", Box::new(NewTerminal)) + .separator() + .action("Copy", Box::new(Copy)) + .action("Paste", Box::new(Paste)) + .action("Select All", Box::new(SelectAll)) + .action("Clear", Box::new(Clear)) + .separator() .action("Close", Box::new(CloseActiveItem { save_intent: None })) }); @@ -258,7 +264,7 @@ impl TerminalView { } } - fn select_all(&mut self, _: &editor::actions::SelectAll, cx: &mut ViewContext) { + fn select_all(&mut self, _: &SelectAll, cx: &mut ViewContext) { self.terminal.update(cx, |term, _| term.select_all()); cx.notify(); }