Skip to content

Commit

Permalink
fix(compatibility): maintain original cursor shape (#659)
Browse files Browse the repository at this point in the history
* fix(compatibility): maintain original cursor shape

* docs(changelog): document change
  • Loading branch information
imsnif authored Aug 25, 2021
1 parent c8d10ee commit 6f2d7d0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions zellij-server/src/panes/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion zellij-server/src/panes/terminal_character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ impl IndexMut<CharsetIndex> for Charsets {

#[derive(Clone, Copy, Debug)]
pub enum CursorShape {
Initial,
Block,
BlinkingBlock,
Underline,
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion zellij-server/src/panes/terminal_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 6f2d7d0

Please sign in to comment.