Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/keymaps/default-macos.json
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,7 @@
"ctrl-cmd-space": "terminal::ShowCharacterPalette",
"cmd-c": "terminal::Copy",
"cmd-v": "terminal::Paste",
"ctrl-cmd-v": "terminal::PasteText",
"cmd-f": "buffer_search::Deploy",
"cmd-a": "editor::SelectAll",
"cmd-k": "terminal::Clear",
Expand Down
1 change: 1 addition & 0 deletions assets/keymaps/default-windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,7 @@
"shift-insert": "terminal::Paste",
"ctrl-v": "terminal::Paste",
"ctrl-shift-v": "terminal::Paste",
"ctrl-alt-v": "terminal::PasteText",
"ctrl-i": "assistant::InlineAssist",
"alt-b": ["terminal::SendText", "\u001bb"],
"alt-f": ["terminal::SendText", "\u001bf"],
Expand Down
2 changes: 2 additions & 0 deletions crates/terminal/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ actions!(
Copy,
/// Pastes from the clipboard.
Paste,
/// Pastes the text from the clipboard.
PasteText,
/// Shows the character palette for special characters.
ShowCharacterPalette,
/// Searches for text in the terminal.
Expand Down
25 changes: 21 additions & 4 deletions crates/terminal_view/src/terminal_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ use std::{
};
use task::TaskId;
use terminal::{
Clear, Copy, Event, HoveredWord, MaybeNavigationTarget, Paste, ScrollLineDown, ScrollLineUp,
ScrollPageDown, ScrollPageUp, ScrollToBottom, ScrollToTop, ShowCharacterPalette, TaskState,
TaskStatus, Terminal, TerminalBounds, ToggleViMode,
Clear, Copy, Event, HoveredWord, MaybeNavigationTarget, Paste, PasteText, ScrollLineDown,
ScrollLineUp, ScrollPageDown, ScrollPageUp, ScrollToBottom, ScrollToTop, ShowCharacterPalette,
TaskState, TaskStatus, Terminal, TerminalBounds, ToggleViMode,
alacritty_terminal::{
index::Point as AlacPoint,
term::{TermMode, point_to_viewport, search::RegexSearch},
Expand Down Expand Up @@ -508,6 +508,7 @@ impl TerminalView {
.separator()
.action("Copy", Box::new(Copy))
.action("Paste", Box::new(Paste))
.action("Paste Text", Box::new(PasteText))
.action("Select All", Box::new(SelectAll))
.action("Clear", Box::new(Clear))
.when(assistant_enabled, |menu| {
Expand Down Expand Up @@ -811,7 +812,7 @@ impl TerminalView {
}

///Attempt to paste the clipboard into the terminal
fn paste(&mut self, _: &Paste, _: &mut Window, cx: &mut Context<Self>) {
fn paste(&mut self, _: &Paste, window: &mut Window, cx: &mut Context<Self>) {
let Some(clipboard) = cx.read_from_clipboard() else {
return;
};
Expand All @@ -820,6 +821,9 @@ impl TerminalView {
Some(ClipboardEntry::Image(image)) if !image.bytes.is_empty() => {
self.forward_ctrl_v(cx);
}
Some(ClipboardEntry::ExternalPaths(paths)) => {
self.add_paths_to_terminal(paths.paths(), window, cx);
}
_ => {
if let Some(text) = clipboard.text() {
self.terminal
Expand All @@ -829,6 +833,18 @@ impl TerminalView {
}
}

///Attempt to paste the clipboard text into the terminal
fn paste_text(&mut self, _: &PasteText, _: &mut Window, cx: &mut Context<Self>) {
let Some(clipboard) = cx.read_from_clipboard() else {
return;
};

if let Some(text) = clipboard.text() {
self.terminal
.update(cx, |terminal, _cx| terminal.paste(&text));
}
}

/// Emits a raw Ctrl+V so TUI agents can read the OS clipboard directly
/// and attach images using their native workflows.
fn forward_ctrl_v(&self, cx: &mut Context<Self>) {
Expand Down Expand Up @@ -1226,6 +1242,7 @@ impl Render for TerminalView {
.on_action(cx.listener(TerminalView::send_keystroke))
.on_action(cx.listener(TerminalView::copy))
.on_action(cx.listener(TerminalView::paste))
.on_action(cx.listener(TerminalView::paste_text))
.on_action(cx.listener(TerminalView::clear))
.on_action(cx.listener(TerminalView::scroll_line_up))
.on_action(cx.listener(TerminalView::scroll_line_down))
Expand Down
Loading