diff options
author | Geert Jansen <geertj@gmail.com> | 2018-01-02 11:32:50 -0500 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2018-01-02 08:32:50 -0800 |
commit | 20aa45c8781f1954de90bb23070454a9581e6969 (patch) | |
tree | 637fa48fa5493d14e191c1f5e26779eb7eec60e0 /src/term/mod.rs | |
parent | b01dc062c704ae3163ca6272dab5d4ec193430a6 (diff) | |
download | alacritty-20aa45c8781f1954de90bb23070454a9581e6969.tar.gz alacritty-20aa45c8781f1954de90bb23070454a9581e6969.zip |
Add support for set-clipboard. (#970)
This allows e.g. tmux to set the clipboard via the OSC 52 escape code.
Diffstat (limited to 'src/term/mod.rs')
-rw-r--r-- | src/term/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs index 72d97ed9..e43ea7b6 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -29,6 +29,7 @@ use index::{self, Point, Column, Line, Linear, IndexRange, Contains, RangeInclus use selection::{self, Span, Selection}; use config::{Config, VisualBellAnimation}; use {MouseCursor, Rgb}; +use copypasta::{Clipboard, Load, Store}; pub mod cell; pub mod color; @@ -1673,6 +1674,17 @@ impl ansi::Handler for Term { self.color_modified[index] = false; } + /// Set the clipboard + #[inline] + fn set_clipboard(&mut self, string: &str) + { + Clipboard::new() + .and_then(|mut clipboard| clipboard.store_primary(string)) + .unwrap_or_else(|err| { + warn!("Error storing selection to clipboard. {}", err); + }); + } + #[inline] fn clear_screen(&mut self, mode: ansi::ClearMode) { trace!("clear_screen: {:?}", mode); |