diff options
author | jc00ke <jesse@jc00ke.com> | 2017-01-19 21:55:38 -0800 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-01-30 07:30:46 -0800 |
commit | 9f064001e20c55cd1b1bf5dfaeea7fd324cdae5d (patch) | |
tree | 67491634fc104b8fde26ddae2fa21a5d7d79c7a4 /src/input.rs | |
parent | 60d6071fb684d3bc15b952dd9cf96db247b91754 (diff) | |
download | alacritty-9f064001e20c55cd1b1bf5dfaeea7fd324cdae5d.tar.gz alacritty-9f064001e20c55cd1b1bf5dfaeea7fd324cdae5d.zip |
Load the primary clipboard when pasting
Paste & PasteSelection are not quite the same. The former should be
pulling from the main clipboard where the latter does not.
Diffstat (limited to 'src/input.rs')
-rw-r--r-- | src/input.rs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/input.rs b/src/input.rs index 09349f04..058cbc0e 100644 --- a/src/input.rs +++ b/src/input.rs @@ -156,25 +156,34 @@ impl Action { } } }, - Action::Paste | + Action::Paste => { + Clipboard::new() + .and_then(|clipboard| clipboard.load_primary() ) + .map(|contents| { self.paste(ctx, contents) }) + .unwrap_or_else(|err| { + err_println!("Error loading data from clipboard. {}", Red(err)); + }); + }, Action::PasteSelection => { Clipboard::new() - .and_then(|clipboard| clipboard.load_selection()) - .map(|contents| { - if ctx.terminal.mode().contains(mode::BRACKETED_PASTE) { - ctx.notifier.notify(&b"\x1b[200~"[..]); - ctx.notifier.notify(contents.into_bytes()); - ctx.notifier.notify(&b"\x1b[201~"[..]); - } else { - ctx.notifier.notify(contents.into_bytes()); - } - }) + .and_then(|clipboard| clipboard.load_selection() ) + .map(|contents| { self.paste(ctx, contents) }) .unwrap_or_else(|err| { warn!("Error loading data from clipboard. {}", Red(err)); }); }, } } + + fn paste<'a, N: Notify>(&self, ctx: &mut ActionContext<'a, N>, contents: String) { + if ctx.terminal.mode().contains(mode::BRACKETED_PASTE) { + ctx.notifier.notify(&b"\x1b[200~"[..]); + ctx.notifier.notify(contents.into_bytes()); + ctx.notifier.notify(&b"\x1b[201~"[..]); + } else { + ctx.notifier.notify(contents.into_bytes()); + } + } } impl From<&'static str> for Action { |