summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/input.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty_terminal/src/input.rs')
-rw-r--r--alacritty_terminal/src/input.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/alacritty_terminal/src/input.rs b/alacritty_terminal/src/input.rs
index fc79b398..0a5cd42b 100644
--- a/alacritty_terminal/src/input.rs
+++ b/alacritty_terminal/src/input.rs
@@ -23,7 +23,6 @@ use std::mem;
use std::ops::RangeInclusive;
use std::time::Instant;
-use copypasta::{Buffer as ClipboardBuffer, Clipboard, Load};
use glutin::{
ElementState, KeyboardInput, ModifiersState, MouseButton, MouseCursor, MouseScrollDelta,
TouchPhase,
@@ -31,6 +30,7 @@ use glutin::{
use unicode_width::UnicodeWidthStr;
use crate::ansi::{ClearMode, Handler};
+use crate::clipboard::ClipboardType;
use crate::config::{self, Key};
use crate::event::{ClickState, Mouse};
use crate::grid::Scroll;
@@ -63,7 +63,7 @@ pub struct Processor<'a, A: 'a> {
pub trait ActionContext {
fn write_to_pty<B: Into<Cow<'static, [u8]>>>(&mut self, _: B);
fn size_info(&self) -> SizeInfo;
- fn copy_selection(&self, _: ClipboardBuffer);
+ fn copy_selection(&mut self, _: ClipboardType);
fn clear_selection(&mut self);
fn update_selection(&mut self, point: Point, side: Side);
fn simple_selection(&mut self, point: Point, side: Side);
@@ -279,11 +279,12 @@ impl Action {
ctx.write_to_pty(s.clone().into_bytes())
},
Action::Copy => {
- ctx.copy_selection(ClipboardBuffer::Primary);
+ ctx.copy_selection(ClipboardType::Primary);
},
Action::Paste => {
- Clipboard::new()
- .and_then(|clipboard| clipboard.load_primary())
+ ctx.terminal_mut()
+ .clipboard()
+ .load(ClipboardType::Primary)
.map(|contents| self.paste(ctx, &contents))
.unwrap_or_else(|err| {
error!("Error loading data from clipboard: {}", Red(err));
@@ -292,8 +293,9 @@ impl Action {
Action::PasteSelection => {
// Only paste if mouse events are not captured by an application
if !mouse_mode {
- Clipboard::new()
- .and_then(|clipboard| clipboard.load_selection())
+ ctx.terminal_mut()
+ .clipboard()
+ .load(ClipboardType::Secondary)
.map(|contents| self.paste(ctx, &contents))
.unwrap_or_else(|err| {
error!("Error loading data from clipboard: {}", Red(err));
@@ -952,9 +954,9 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
/// Copy text selection.
fn copy_selection(&mut self) {
if self.save_to_clipboard {
- self.ctx.copy_selection(ClipboardBuffer::Primary);
+ self.ctx.copy_selection(ClipboardType::Primary);
}
- self.ctx.copy_selection(ClipboardBuffer::Selection);
+ self.ctx.copy_selection(ClipboardType::Secondary);
}
}
@@ -965,6 +967,7 @@ mod tests {
use glutin::{ElementState, Event, ModifiersState, MouseButton, VirtualKeyCode, WindowEvent};
+ use crate::clipboard::{Clipboard, ClipboardType};
use crate::config::{self, ClickHandler, Config};
use crate::event::{ClickState, Mouse, WindowChanges};
use crate::grid::Scroll;
@@ -974,7 +977,6 @@ mod tests {
use crate::term::{SizeInfo, Term, TermMode};
use super::{Action, Binding, Processor};
- use copypasta::Buffer as ClipboardBuffer;
const KEY: VirtualKeyCode = VirtualKeyCode::Key0;
@@ -1004,7 +1006,7 @@ mod tests {
fn simple_selection(&mut self, _point: Point, _side: Side) {}
- fn copy_selection(&self, _buffer: ClipboardBuffer) {}
+ fn copy_selection(&mut self, _: ClipboardType) {}
fn clear_selection(&mut self) {}
@@ -1095,7 +1097,7 @@ mod tests {
dpr: 1.0,
};
- let mut terminal = Term::new(&config, size, MessageBuffer::new());
+ let mut terminal = Term::new(&config, size, MessageBuffer::new(), Clipboard::new_nop());
let mut mouse = Mouse::default();
mouse.click_state = $initial_state;