Skip to content

Commit

Permalink
support bracketed paste mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lotabout committed Jan 4, 2021
1 parent 7d5051a commit 354c015
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ log = "0.4.6"
env_logger = "0.8.2"
time = "0.2.23"
clap = "2.26.2"
tuikit = "0.4.2"
tuikit = "0.4.3"
vte = "0.9.0"
fuzzy-matcher = "0.3.7"
rayon = "1.0.3"
Expand Down
22 changes: 19 additions & 3 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct Query {
fz_query_history_before: Vec<String>,
fz_query_history_after: Vec<String>,

pasted: Option<String>,

theme: Arc<ColorTheme>,
}

Expand All @@ -55,6 +57,8 @@ impl Query {
fz_query_history_before: Vec::new(),
fz_query_history_after: Vec::new(),

pasted: None,

theme: Arc::new(*DEFAULT_THEME),
}
}
Expand Down Expand Up @@ -443,9 +447,10 @@ impl EventHandler for Query {
let cmd_after_len = self.cmd_after.len();

match event {
EvActAddChar(ch) => {
self.act_add_char(*ch);
}
EvActAddChar(ch) => match self.pasted.as_mut() {
Some(pasted) => pasted.push(*ch),
None => self.act_add_char(*ch),
},

EvActDeleteChar | EvActDeleteCharEOF => {
self.act_delete_char();
Expand Down Expand Up @@ -513,6 +518,17 @@ impl EventHandler for Query {
self.act_query_toggle_interactive();
}

EvInputKey(Key::BracketedPasteStart) => {
self.pasted.replace(String::new());
}

EvInputKey(Key::BracketedPasteEnd) => {
let pasted = self.pasted.take().unwrap_or_else(|| String::new());
for ch in pasted.chars() {
self.act_add_char(ch);
}
}

_ => {}
}

Expand Down

0 comments on commit 354c015

Please sign in to comment.