diff options
Diffstat (limited to 'helix-tui/src/terminal.rs')
-rw-r--r-- | helix-tui/src/terminal.rs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/helix-tui/src/terminal.rs b/helix-tui/src/terminal.rs index ad1e8da3..e8f8f359 100644 --- a/helix-tui/src/terminal.rs +++ b/helix-tui/src/terminal.rs @@ -8,6 +8,19 @@ enum ResizeBehavior { Auto, } +#[derive(Debug)] +/// UNSTABLE +pub enum CursorKind { + /// █ + Block, + /// | + // Bar, + /// _ + // Underline, + /// Hidden cursor, can set cursor position with this to let IME have correct cursor position. + Hidden, +} + #[derive(Debug, Clone, PartialEq)] /// UNSTABLE pub struct Viewport { @@ -147,7 +160,11 @@ where /// Synchronizes terminal size, calls the rendering closure, flushes the current internal state /// and prepares for the next draw call. - pub fn draw(&mut self, cursor_position: Option<(u16, u16)>) -> io::Result<()> { + pub fn draw( + &mut self, + cursor_position: Option<(u16, u16)>, + cursor_kind: CursorKind, + ) -> io::Result<()> { // // Autoresize - otherwise we get glitches if shrinking or potential desync between widgets // // and the terminal (if growing), which may OOB. // self.autoresize()?; @@ -162,12 +179,13 @@ where // Draw to stdout self.flush()?; - match cursor_position { - None => self.hide_cursor()?, - Some((x, y)) => { - self.show_cursor()?; - self.set_cursor(x, y)?; - } + if let Some((x, y)) = cursor_position { + self.set_cursor(x, y)?; + } + + match cursor_kind { + CursorKind::Block => self.show_cursor()?, + CursorKind::Hidden => self.hide_cursor()?, } // Swap buffers |