mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-14 14:11:34 +00:00
Add bracketed paste support
This commit is contained in:
parent
cfc956d78f
commit
8349ead6b2
2 changed files with 13 additions and 2 deletions
|
@ -7,7 +7,7 @@ use alacritty_terminal::{
|
|||
event_loop::{EventLoop, Msg, Notifier},
|
||||
grid::Scroll,
|
||||
sync::FairMutex,
|
||||
term::SizeInfo,
|
||||
term::{SizeInfo, TermMode},
|
||||
tty::{self, setup_env},
|
||||
Term,
|
||||
};
|
||||
|
@ -228,6 +228,17 @@ impl TerminalConnection {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
///Paste text into the terminal
|
||||
pub fn paste(&mut self, text: &str) {
|
||||
if self.term.lock().mode().contains(TermMode::BRACKETED_PASTE) {
|
||||
self.write_to_pty("\x1b[200~".to_string());
|
||||
self.write_to_pty(text.replace('\x1b', "").to_string());
|
||||
self.write_to_pty("\x1b[201~".to_string());
|
||||
} else {
|
||||
self.write_to_pty(text.replace("\r\n", "\r").replace('\n', "\r"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TerminalConnection {
|
||||
|
|
|
@ -191,7 +191,7 @@ impl Terminal {
|
|||
fn paste(&mut self, _: &Paste, cx: &mut ViewContext<Self>) {
|
||||
if let Some(item) = cx.read_from_clipboard() {
|
||||
self.connection.update(cx, |connection, _| {
|
||||
connection.write_to_pty(item.text().to_owned());
|
||||
connection.paste(item.text());
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue