Skip to content

Commit

Permalink
Support bracketed paste (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximbaz authored Jul 10, 2023
1 parent 1faadea commit ebb9b38
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub enum Event {
Redraw,
Click(MouseEvent),
Input(KeyEvent),
Paste(String),
Message(Content),
Resize { cols: u16, rows: u16 },
Quit(Option<anyhow::Error>),
Expand Down Expand Up @@ -155,6 +156,7 @@ async fn run_single_threaded(relink: bool) -> anyhow::Result<()> {
tx.send(Event::Resize { cols, rows }).await.unwrap()
}
Ok(CEvent::Mouse(button)) => tx.send(Event::Click(button)).await.unwrap(),
Ok(CEvent::Paste(content)) => tx.send(Event::Paste(content)).await.unwrap(),
_ => (),
}
}
Expand Down Expand Up @@ -396,6 +398,12 @@ async fn run_single_threaded(relink: bool) -> anyhow::Result<()> {
}
_ => app.on_key(event).await?,
},
Some(Event::Paste(content)) => {
let multi_line_state = app.is_multiline_input;
app.is_multiline_input = true;
content.chars().for_each(|c| app.get_input().put_char(c));
app.is_multiline_input = multi_line_state;
}
Some(Event::Message(content)) => {
if let Err(e) = app.on_message(content).await {
error!("failed on incoming message: {}", e);
Expand Down

0 comments on commit ebb9b38

Please sign in to comment.