From 5370e88520cd8ef51df689a7a8624592bcbbf313 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 11 Nov 2019 08:54:47 -0800 Subject: [PATCH] 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. --- src/frontend/gui/termwindow.rs | 2 +- src/localtab.rs | 5 +++++ src/mux/tab.rs | 1 + src/server/tab.rs | 5 +++++ src/termwiztermtab.rs | 5 +++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index c861a8abd..255b8334f 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -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()?)?; diff --git a/src/localtab.rs b/src/localtab.rs index 2a70bb50c..e747e548a 100644 --- a/src/localtab.rs +++ b/src/localtab.rs @@ -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 { + let terminal = self.terminal.borrow(); + Some(terminal.get_selection_text()) + } } impl LocalTab { diff --git a/src/mux/tab.rs b/src/mux/tab.rs index 1f2bdd404..904b347ac 100644 --- a/src/mux/tab.rs +++ b/src/mux/tab.rs @@ -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; + fn selection_text(&self) -> Option; fn trickle_paste(&self, text: String) -> Fallible<()> { if text.len() <= PASTE_CHUNK_SIZE { diff --git a/src/server/tab.rs b/src/server/tab.rs index 8462b8dac..ab713ce2a 100644 --- a/src/server/tab.rs +++ b/src/server/tab.rs @@ -312,6 +312,11 @@ impl Tab for ClientTab { .lock() .unwrap() } + + fn selection_text(&self) -> Option { + // FIXME: get selection from peer or the surface + None + } } struct RenderableInner { diff --git a/src/termwiztermtab.rs b/src/termwiztermtab.rs index ed2728a62..778f8154d 100644 --- a/src/termwiztermtab.rs +++ b/src/termwiztermtab.rs @@ -294,6 +294,11 @@ impl Tab for TermWizTerminalTab { .lock() .unwrap() } + + fn selection_text(&self) -> Option { + // FIXME: grab it from the surface + None + } } pub struct TermWizTerminal {