1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00

implement explicit Copy keybinding action

previously we would only ever copy to the clipboard when the selection
was changed.

Now we respect the Copy keypress and have it re-copy the selection
into the clipboard.
This commit is contained in:
Wez Furlong 2019-11-11 08:54:47 -08:00
parent a83851dcca
commit 5370e88520
5 changed files with 17 additions and 1 deletions

View File

@ -646,7 +646,7 @@ impl TermWindow {
// self.toggle_full_screen(),
}
Copy => {
// Nominally copy, but that is implicit, so NOP
self.clipboard.set_contents(tab.selection_text())?;
}
Paste => {
tab.trickle_paste(self.clipboard.get_contents()?)?;

View File

@ -93,6 +93,11 @@ impl Tab for LocalTab {
.selection_range()
.map(|r| r.clip_to_viewport(terminal.get_viewport_offset(), rows))
}
fn selection_text(&self) -> Option<String> {
let terminal = self.terminal.borrow();
Some(terminal.get_selection_text())
}
}
impl LocalTab {

View File

@ -67,6 +67,7 @@ pub trait Tab: Downcast {
/// (eg: it has been normalized and had clip_to_viewport called
/// on it prior to being returned)
fn selection_range(&self) -> Option<SelectionRange>;
fn selection_text(&self) -> Option<String>;
fn trickle_paste(&self, text: String) -> Fallible<()> {
if text.len() <= PASTE_CHUNK_SIZE {

View File

@ -312,6 +312,11 @@ impl Tab for ClientTab {
.lock()
.unwrap()
}
fn selection_text(&self) -> Option<String> {
// FIXME: get selection from peer or the surface
None
}
}
struct RenderableInner {

View File

@ -294,6 +294,11 @@ impl Tab for TermWizTerminalTab {
.lock()
.unwrap()
}
fn selection_text(&self) -> Option<String> {
// FIXME: grab it from the surface
None
}
}
pub struct TermWizTerminal {