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/ansi.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/ansi.rs')
-rw-r--r-- | src/ansi.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/ansi.rs b/src/ansi.rs index 3d66b497..8ff7d06b 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -18,7 +18,7 @@ use std::ops::Range; use std::str; use vte; - +use base64; use index::{Column, Line, Contains}; use ::{MouseCursor, Rgb}; @@ -342,6 +342,9 @@ pub trait Handler { /// Reset an indexed color to original value fn reset_color(&mut self, usize) {} + /// Set the clipboard + fn set_clipboard(&mut self, &str) {} + /// Run the dectest routine fn dectest(&mut self) {} } @@ -820,6 +823,24 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W> } } + // Set clipboard + b"52" => { + if params.len() < 3 { + return unhandled!(); + } + + match params[2] { + b"?" => unhandled!(), + selection => { + if let Ok(string) = base64::decode(selection) { + if let Ok(utf8_string) = str::from_utf8(&string) { + self.handler.set_clipboard(utf8_string); + } + } + } + } + } + // Reset color index b"104" => { // Reset all color indexes when no parameters are given |