fix(compatibility): only send bracketed paste to terminals requesting it (#658)

* fix(compatibility): only send bracketed paste to terminals requesting it

* docs(changelog): update change

* style(fmt): make rustfmt happy
This commit is contained in:
Aram Drevekenin 2021-08-24 10:24:10 +02:00 committed by GitHub
parent 7a2f86db1b
commit c8d10ee64d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View file

@ -21,9 +21,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* Fix various shells (eg. nushell) unexpectedly exiting when the user presses ctrl-c (https://github.com/zellij-org/zellij/pull/648)
* Fix line wrapping while scrolling (https://github.com/zellij-org/zellij/pull/650)
* Indicate to the user when text is copied to the clipboard with the mouse (https://github.com/zellij-org/zellij/pull/642)
* Terminal compatibility: properly paste multilines (https://github.com/zellij-org/zellij/pull/653 + https://github.com/zellij-org/zellij/pull/658)
* Terminal compatibility: fix progress bar line overflow (http://github.com/zellij-org/zellij/pull/656)
* Add action to toggle between tabs `ToggleTab`, bound by default to [TAB] in tab mode (https://github.com/zellij-org/zellij/pull/622)
## [0.15.0] - 2021-07-19
* Kill children properly (https://github.com/zellij-org/zellij/pull/601)
* Change name of `Run` binding for actions (https://github.com/zellij-org/zellij/pull/602)

View file

@ -351,7 +351,8 @@ pub struct Grid {
pub changed_colors: Option<[Option<AnsiCode>; 256]>,
pub should_render: bool,
pub cursor_key_mode: bool, // DECCKM - when set, cursor keys should send ANSI direction codes (eg. "OD") instead of the arrow keys (eg. "")
pub erasure_mode: bool, // ERM
pub bracketed_paste_mode: bool, // when set, paste instructions to the terminal should be escaped with a special sequence
pub erasure_mode: bool, // ERM
pub insert_mode: bool,
pub disable_linewrap: bool,
pub clear_viewport_before_rendering: bool,
@ -390,6 +391,7 @@ impl Grid {
height: rows,
should_render: true,
cursor_key_mode: false,
bracketed_paste_mode: false,
erasure_mode: false,
insert_mode: false,
disable_linewrap: false,
@ -1630,6 +1632,9 @@ impl Perform for Grid {
};
if first_intermediate_is_questionmark {
match params_iter.next().map(|param| param[0]) {
Some(2004) => {
self.bracketed_paste_mode = false;
}
Some(1049) => {
if let Some((
alternative_lines_above,
@ -1683,6 +1688,9 @@ impl Perform for Grid {
self.show_cursor();
self.mark_for_rerender();
}
Some(2004) => {
self.bracketed_paste_mode = true;
}
Some(1049) => {
let current_lines_above = std::mem::replace(
&mut self.lines_above,

View file

@ -144,6 +144,15 @@ impl Pane for TerminalPane {
return "OB".as_bytes().to_vec();
}
}
[27, 91, 50, 48, 48, 126] | [27, 91, 50, 48, 49, 126] => {
if !self.grid.bracketed_paste_mode {
// Zellij itself operates in bracketed paste mode, so the terminal sends these
// instructions (bracketed paste start and bracketed paste end respectively)
// when pasting input. We only need to make sure not to send them to terminal
// panes who do not work in this mode
return vec![];
}
}
_ => {}
};
input_bytes