summaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-09-09 18:02:41 +0200
committerCanop <cano.petrole@gmail.com>2020-09-09 18:02:41 +0200
commit5edab5fd73ac38df12ff4ce7db21091f6bd8acbb (patch)
tree4d6fcdfae4f9b8a45a8529cff2e9df184b578a1a /src/command
parent752d44bb17b88da634818162113c9a8a0fb08d59 (diff)
ctrl-v now inserts the clipboard content in the input
when the "clipboard" feature is on. This behaviour may be mapped to another key, it's based on the new `:input_paste` verb
Diffstat (limited to 'src/command')
-rw-r--r--src/command/mod.rs4
-rw-r--r--src/command/panel_input.rs (renamed from src/command/event.rs)16
2 files changed, 18 insertions, 2 deletions
diff --git a/src/command/mod.rs b/src/command/mod.rs
index 7655b92..70e89f5 100644
--- a/src/command/mod.rs
+++ b/src/command/mod.rs
@@ -1,6 +1,6 @@
mod command;
mod completion;
-mod event;
+mod panel_input;
mod parts;
mod sequence;
mod scroll;
@@ -9,7 +9,7 @@ mod trigger_type;
pub use {
command::Command,
completion::Completions,
- event::PanelInput,
+ panel_input::PanelInput,
parts::CommandParts,
sequence::Sequence,
scroll::ScrollCommand,
diff --git a/src/command/event.rs b/src/command/panel_input.rs
index f7b2a54..f8e3af0 100644
--- a/src/command/event.rs
+++ b/src/command/panel_input.rs
@@ -89,6 +89,22 @@ impl PanelInput {
Internal::input_go_word_right => self.input_field.move_word_right(),
Internal::input_go_to_start => self.input_field.move_to_start(),
Internal::input_go_to_end => self.input_field.move_to_end(),
+ #[cfg(feature="clipboard")]
+ Internal::input_paste => {
+ match terminal_clipboard::get_string() {
+ Ok(pasted) => {
+ for c in pasted.chars()
+ .filter(|c| c.is_alphanumeric() || c.is_ascii_punctuation())
+ {
+ self.input_field.put_char(c);
+ }
+ }
+ Err(e) => {
+ warn!("Error in reading clipboard: {:?}", e);
+ }
+ }
+ true
+ }
_ => false,
}
} else {