From 6f2d7d01763e78cc05f5c02f2f56feb1082825cb Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Wed, 25 Aug 2021 13:43:18 +0200 Subject: [PATCH] fix(compatibility): maintain original cursor shape (#659) * fix(compatibility): maintain original cursor shape * docs(changelog): document change --- CHANGELOG.md | 1 + zellij-server/src/panes/grid.rs | 5 +++-- zellij-server/src/panes/terminal_character.rs | 3 ++- zellij-server/src/panes/terminal_pane.rs | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a69892222f..8ee3dbc595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * 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) +* Terminal compatibility: properly handle cursor shape changes in eg. Neovim (https://github.com/zellij-org/zellij/pull/659) ## [0.15.0] - 2021-07-19 diff --git a/zellij-server/src/panes/grid.rs b/zellij-server/src/panes/grid.rs index a4066ebf1f..cb03eb6aea 100644 --- a/zellij-server/src/panes/grid.rs +++ b/zellij-server/src/panes/grid.rs @@ -1219,7 +1219,7 @@ impl Grid { self.active_charset = Default::default(); self.erasure_mode = false; self.disable_linewrap = false; - self.cursor.change_shape(CursorShape::Block); + self.cursor.change_shape(CursorShape::Initial); self.output_buffer.update_all_lines(); self.changed_colors = None; } @@ -1821,7 +1821,8 @@ impl Perform for Grid { // DECSCUSR (CSI Ps SP q) -- Set Cursor Style. let cursor_style_id = next_param_or(0); let shape = match cursor_style_id { - 0 | 2 => Some(CursorShape::Block), + 0 => Some(CursorShape::Initial), + 2 => Some(CursorShape::Block), 1 => Some(CursorShape::BlinkingBlock), 3 => Some(CursorShape::BlinkingUnderline), 4 => Some(CursorShape::Underline), diff --git a/zellij-server/src/panes/terminal_character.rs b/zellij-server/src/panes/terminal_character.rs index 2e1a018d3a..543d23e12d 100644 --- a/zellij-server/src/panes/terminal_character.rs +++ b/zellij-server/src/panes/terminal_character.rs @@ -724,6 +724,7 @@ impl IndexMut for Charsets { #[derive(Clone, Copy, Debug)] pub enum CursorShape { + Initial, Block, BlinkingBlock, Underline, @@ -750,7 +751,7 @@ impl Cursor { is_hidden: false, pending_styles: CharacterStyles::new(), charsets: Default::default(), - shape: CursorShape::Block, + shape: CursorShape::Initial, } } pub fn change_shape(&mut self, shape: CursorShape) { diff --git a/zellij-server/src/panes/terminal_pane.rs b/zellij-server/src/panes/terminal_pane.rs index 55bd918546..d34050232b 100644 --- a/zellij-server/src/panes/terminal_pane.rs +++ b/zellij-server/src/panes/terminal_pane.rs @@ -344,7 +344,8 @@ impl Pane for TerminalPane { } fn cursor_shape_csi(&self) -> String { match self.grid.cursor_shape() { - CursorShape::Block => "\u{1b}[0 q".to_string(), + CursorShape::Initial => "\u{1b}[0 q".to_string(), + CursorShape::Block => "\u{1b}[2 q".to_string(), CursorShape::BlinkingBlock => "\u{1b}[1 q".to_string(), CursorShape::Underline => "\u{1b}[4 q".to_string(), CursorShape::BlinkingUnderline => "\u{1b}[3 q".to_string(),