mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 06:54:45 +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:
parent
a83851dcca
commit
5370e88520
@ -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()?)?;
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user