Skip to content

Commit

Permalink
fix(compatibility): only send bracketed paste to terminals requesting…
Browse files Browse the repository at this point in the history
… it (#658)

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

* docs(changelog): update change

* style(fmt): make rustfmt happy
  • Loading branch information
imsnif authored Aug 24, 2021
1 parent 7a2f86d commit c8d10ee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion zellij-server/src/panes/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions zellij-server/src/panes/terminal_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c8d10ee

Please sign in to comment.