diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index eb2d65dff..d0c6b3a65 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -25,6 +25,7 @@ use std::sync::Arc; use term::color::ColorPalette; use term::{CursorPosition, Line, Underline}; use termwiz::color::RgbColor; +use termwiz::surface::CursorShape; #[derive(Debug, Clone, Copy)] struct RowsAndCols { @@ -1053,6 +1054,7 @@ impl TermWindow { CursorPosition { x: cursor.x, y: cursor.y + first_line_offset as i64, + ..cursor } }; @@ -1158,6 +1160,7 @@ impl TermWindow { CursorPosition { x: cursor.x, y: cursor.y + first_line_offset as i64, + ..cursor } }; @@ -1774,7 +1777,9 @@ impl TermWindow { palette: &ColorPalette, ) -> (Color, Color) { let selected = selection.contains(&cell_idx); - let is_cursor = line_idx as i64 == cursor.y && cursor.x == cell_idx; + let is_cursor = line_idx as i64 == cursor.y + && cursor.x == cell_idx + && cursor.shape != CursorShape::Hidden; let (fg_color, bg_color) = match (selected, is_cursor) { // Normally, render the cell as configured diff --git a/src/server/tab.rs b/src/server/tab.rs index 6a0105e80..215daab0e 100644 --- a/src/server/tab.rs +++ b/src/server/tab.rs @@ -395,8 +395,14 @@ impl RenderableInner { impl Renderable for RenderableState { fn get_cursor_position(&self) -> CursorPosition { - let (x, y) = self.inner.borrow().surface.cursor_position(); - CursorPosition { x, y: y as i64 } + let surface = &self.inner.borrow().surface; + let (x, y) = surface.cursor_position(); + let shape = surface.cursor_shape(); + CursorPosition { + x, + y: y as i64, + shape, + } } fn get_dirty_lines(&self) -> Vec<(usize, Cow, Range)> { diff --git a/src/termwiztermtab.rs b/src/termwiztermtab.rs index 892e0a768..2163df66a 100644 --- a/src/termwiztermtab.rs +++ b/src/termwiztermtab.rs @@ -64,8 +64,14 @@ impl std::io::Write for RenderableState { impl Renderable for RenderableState { fn get_cursor_position(&self) -> CursorPosition { - let (x, y) = self.inner.borrow().surface.cursor_position(); - CursorPosition { x, y: y as i64 } + let surface = &self.inner.borrow().surface; + let (x, y) = surface.cursor_position(); + let shape = surface.cursor_shape(); + CursorPosition { + x, + y: y as i64, + shape, + } } fn get_dirty_lines(&self) -> Vec<(usize, Cow, Range)> { diff --git a/term/src/lib.rs b/term/src/lib.rs index 273277235..6b0373bdf 100644 --- a/term/src/lib.rs +++ b/term/src/lib.rs @@ -80,6 +80,7 @@ pub enum Position { pub struct CursorPosition { pub x: usize, pub y: VisibleRowIndex, + pub shape: termwiz::surface::CursorShape, } pub mod color; diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index eb1970fe9..a80ed5bcf 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -17,6 +17,7 @@ use termwiz::escape::osc::{ChangeColorPair, ColorOrQuery, ITermFileData, ITermPr use termwiz::escape::{Action, ControlCode, Esc, EscCode, OneBased, OperatingSystemCommand, CSI}; use termwiz::hyperlink::Rule as HyperlinkRule; use termwiz::image::{ImageCell, ImageData, TextureCoordinate}; +use termwiz::surface::CursorShape; struct TabStop { tabs: Vec, @@ -777,6 +778,7 @@ impl TerminalState { let new_position = CursorPosition { x: event.x, y: event.y as VisibleRowIndex, + ..self.mouse_position }; if new_position != self.mouse_position { @@ -1218,6 +1220,11 @@ impl TerminalState { CursorPosition { x: self.cursor.x, y: self.cursor.y + self.viewport_offset, + shape: if self.cursor_visible { + self.mouse_position.shape + } else { + CursorShape::Hidden + }, } } diff --git a/term/src/test/mod.rs b/term/src/test/mod.rs index d1b3d1b6d..cb557e105 100644 --- a/term/src/test/mod.rs +++ b/term/src/test/mod.rs @@ -12,6 +12,7 @@ use std::cell::RefCell; use std::sync::Arc; use termwiz::escape::csi::{Edit, EraseInDisplay, EraseInLine}; use termwiz::escape::{OneBased, OperatingSystemCommand, CSI}; +use termwiz::surface::CursorShape; struct TestHost { title: String, @@ -235,7 +236,11 @@ impl TestTerm { fn assert_cursor_pos(&self, x: usize, y: i64, reason: Option<&str>) { let cursor = self.cursor_pos(); - let expect = CursorPosition { x, y }; + let expect = CursorPosition { + x, + y, + shape: CursorShape::Default, + }; assert_eq!( cursor, expect, "actual cursor (left) didn't match expected cursor (right) reason={:?}", diff --git a/termwiz/src/surface/mod.rs b/termwiz/src/surface/mod.rs index 0ff8fa873..dd7a5c30b 100644 --- a/termwiz/src/surface/mod.rs +++ b/termwiz/src/surface/mod.rs @@ -181,6 +181,10 @@ impl Surface { (self.xpos, self.ypos) } + pub fn cursor_shape(&self) -> CursorShape { + self.cursor_shape + } + pub fn title(&self) -> &str { &self.title }