diff options
Diffstat (limited to 'alacritty/src/input.rs')
-rw-r--r-- | alacritty/src/input.rs | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index c5f41b6e..a66511cf 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -60,7 +60,7 @@ pub struct Processor<T: EventListener, A: ActionContext<T>> { } pub trait ActionContext<T: EventListener> { - fn write_to_pty<B: Into<Cow<'static, [u8]>>>(&mut self, _data: B) {} + fn write_to_pty<B: Into<Cow<'static, [u8]>>>(&self, _data: B) {} fn mark_dirty(&mut self) {} fn size_info(&self) -> SizeInfo; fn copy_selection(&mut self, _ty: ClipboardType) {} @@ -107,6 +107,7 @@ pub trait ActionContext<T: EventListener> { fn toggle_vi_mode(&mut self) {} fn hint_state(&mut self) -> &mut HintState; fn hint_input(&mut self, _character: char) {} + fn paste(&mut self, _text: &str) {} } impl Action { @@ -243,11 +244,11 @@ impl<T: EventListener> Execute<T> for Action { Action::ClearSelection => ctx.clear_selection(), Action::Paste => { let text = ctx.clipboard_mut().load(ClipboardType::Clipboard); - paste(ctx, &text); + ctx.paste(&text); }, Action::PasteSelection => { let text = ctx.clipboard_mut().load(ClipboardType::Selection); - paste(ctx, &text); + ctx.paste(&text); }, Action::ToggleFullscreen => ctx.window_mut().toggle_fullscreen(), #[cfg(target_os = "macos")] @@ -324,26 +325,6 @@ impl<T: EventListener> Execute<T> for Action { } } -fn paste<T: EventListener, A: ActionContext<T>>(ctx: &mut A, contents: &str) { - if ctx.search_active() { - for c in contents.chars() { - ctx.search_input(c); - } - } else if ctx.terminal().mode().contains(TermMode::BRACKETED_PASTE) { - ctx.write_to_pty(&b"\x1b[200~"[..]); - ctx.write_to_pty(contents.replace("\x1b", "").into_bytes()); - ctx.write_to_pty(&b"\x1b[201~"[..]); - } else { - // In non-bracketed (ie: normal) mode, terminal applications cannot distinguish - // pasted data from keystrokes. - // In theory, we should construct the keystrokes needed to produce the data we are - // pasting... since that's neither practical nor sensible (and probably an impossible - // task to solve in a general way), we'll just replace line breaks (windows and unix - // style) with a single carriage return (\r, which is what the Enter key produces). - ctx.write_to_pty(contents.replace("\r\n", "\r").replace("\n", "\r").into_bytes()); - } -} - #[derive(Debug, Clone, PartialEq)] pub enum MouseState { Url(Url), @@ -680,7 +661,6 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { } self.ctx.scheduler_mut().unschedule(TimerId::SelectionScrolling); - self.copy_selection(); } pub fn mouse_wheel_input(&mut self, delta: MouseScrollDelta, phase: TouchPhase) { @@ -965,14 +945,6 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { } } - /// Copy text selection. - fn copy_selection(&mut self) { - if self.ctx.config().selection.save_to_clipboard { - self.ctx.copy_selection(ClipboardType::Clipboard); - } - self.ctx.copy_selection(ClipboardType::Selection); - } - /// Trigger redraw when URL highlight changed. #[inline] fn update_url_state(&mut self, mouse_state: &MouseState) { |