diff options
Diffstat (limited to 'helix-tui/src/backend')
-rw-r--r-- | helix-tui/src/backend/crossterm.rs | 13 | ||||
-rw-r--r-- | helix-tui/src/backend/mod.rs | 3 | ||||
-rw-r--r-- | helix-tui/src/backend/test.rs | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/helix-tui/src/backend/crossterm.rs b/helix-tui/src/backend/crossterm.rs index f6703e14..189f9dce 100644 --- a/helix-tui/src/backend/crossterm.rs +++ b/helix-tui/src/backend/crossterm.rs @@ -3,9 +3,10 @@ use crate::{ buffer::Cell, layout::Rect, style::{Color, Modifier}, + terminal::CursorKind, }; use crossterm::{ - cursor::{Hide, MoveTo, Show}, + cursor::{CursorShape, Hide, MoveTo, SetCursorShape, Show}, execute, queue, style::{ Attribute as CAttribute, Color as CColor, Print, SetAttribute, SetBackgroundColor, @@ -93,8 +94,14 @@ where map_error(execute!(self.buffer, Hide)) } - fn show_cursor(&mut self) -> io::Result<()> { - map_error(execute!(self.buffer, Show)) + fn show_cursor(&mut self, kind: CursorKind) -> io::Result<()> { + let shape = match kind { + CursorKind::Block => CursorShape::Block, + CursorKind::Bar => CursorShape::Line, + CursorKind::Underline => CursorShape::UnderScore, + CursorKind::Hidden => unreachable!(), + }; + map_error(execute!(self.buffer, Show, SetCursorShape(shape))) } fn get_cursor(&mut self) -> io::Result<(u16, u16)> { diff --git a/helix-tui/src/backend/mod.rs b/helix-tui/src/backend/mod.rs index ed125200..5cf21768 100644 --- a/helix-tui/src/backend/mod.rs +++ b/helix-tui/src/backend/mod.rs @@ -2,6 +2,7 @@ use std::io; use crate::buffer::Cell; use crate::layout::Rect; +use crate::terminal::CursorKind; #[cfg(feature = "crossterm")] mod crossterm; @@ -16,7 +17,7 @@ pub trait Backend { where I: Iterator<Item = (u16, u16, &'a Cell)>; fn hide_cursor(&mut self) -> Result<(), io::Error>; - fn show_cursor(&mut self) -> Result<(), io::Error>; + fn show_cursor(&mut self, kind: CursorKind) -> Result<(), io::Error>; fn get_cursor(&mut self) -> Result<(u16, u16), io::Error>; fn set_cursor(&mut self, x: u16, y: u16) -> Result<(), io::Error>; fn clear(&mut self) -> Result<(), io::Error>; diff --git a/helix-tui/src/backend/test.rs b/helix-tui/src/backend/test.rs index 46b37261..4681831d 100644 --- a/helix-tui/src/backend/test.rs +++ b/helix-tui/src/backend/test.rs @@ -2,6 +2,7 @@ use crate::{ backend::Backend, buffer::{Buffer, Cell}, layout::Rect, + terminal::CursorKind, }; use std::{fmt::Write, io}; use unicode_width::UnicodeWidthStr; @@ -122,7 +123,7 @@ impl Backend for TestBackend { Ok(()) } - fn show_cursor(&mut self) -> Result<(), io::Error> { + fn show_cursor(&mut self, _kind: CursorKind) -> Result<(), io::Error> { self.cursor = true; Ok(()) } |