From a752066bfa281f236b8d171cbc8f6e5a5a940297 Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Mon, 24 Sep 2018 20:12:45 +0800 Subject: Allow copying selection to primary clipboard A new configuration option `save_to_clipboard` has been added to the `selection` section of the configuration. This allows writing every selection to the primary system clipboard when it is set to `true`. On linux the selection is still written to the selection clipboard, independent of the value of the `save_to_clipboard` setting. --- src/event.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index ec17034f..da63d5fd 100644 --- a/src/event.rs +++ b/src/event.rs @@ -8,7 +8,7 @@ use std::time::{Instant}; use serde_json as json; use parking_lot::MutexGuard; use glutin::{self, ModifiersState, Event, ElementState}; -use copypasta::{Clipboard, Load, Store}; +use copypasta::{Clipboard, Load, Store, Buffer as ClipboardBuffer}; use ansi::{Handler, ClearMode}; use grid::Scroll; @@ -64,7 +64,7 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { self.terminal.clear_screen(ClearMode::Saved); } - fn copy_selection(&self, buffer: ::copypasta::Buffer) { + fn copy_selection(&self, buffer: ClipboardBuffer) { if let Some(selected) = self.terminal.selection_to_string() { if !selected.is_empty() { Clipboard::new() @@ -238,6 +238,7 @@ pub struct Processor { last_modifiers: ModifiersState, pending_events: Vec, window_changes: WindowChanges, + save_to_clipboard: bool, } /// Notify that the terminal was resized @@ -281,6 +282,7 @@ impl Processor { last_modifiers: Default::default(), pending_events: Vec::with_capacity(4), window_changes: Default::default(), + save_to_clipboard: config.selection().save_to_clipboard, } } @@ -442,6 +444,7 @@ impl Processor { mouse_config: &self.mouse_config, key_bindings: &self.key_bindings[..], mouse_bindings: &self.mouse_bindings[..], + save_to_clipboard: self.save_to_clipboard, }; let mut window_is_focused = window.is_focused; @@ -496,5 +499,6 @@ impl Processor { self.key_bindings = config.key_bindings().to_vec(); self.mouse_bindings = config.mouse_bindings().to_vec(); self.mouse_config = config.mouse().to_owned(); + self.save_to_clipboard = config.selection().save_to_clipboard; } } -- cgit