diff options
Diffstat (limited to 'helix-term/src/compositor.rs')
-rw-r--r-- | helix-term/src/compositor.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs index c2cfa3a7..628c4e13 100644 --- a/helix-term/src/compositor.rs +++ b/helix-term/src/compositor.rs @@ -68,7 +68,7 @@ pub trait Component: Any + AnyComponent { use anyhow::Error; use std::io::stdout; -use tui::backend::CrosstermBackend; +use tui::backend::{Backend, CrosstermBackend}; type Terminal = tui::terminal::Terminal<CrosstermBackend<std::io::Stdout>>; pub struct Compositor { @@ -99,6 +99,21 @@ impl Compositor { .expect("Unable to resize terminal") } + pub fn save_cursor(&mut self) { + if self.terminal.cursor_kind() == CursorKind::Hidden { + self.terminal + .backend_mut() + .show_cursor(CursorKind::Block) + .ok(); + } + } + + pub fn load_cursor(&mut self) { + if self.terminal.cursor_kind() == CursorKind::Hidden { + self.terminal.backend_mut().hide_cursor().ok(); + } + } + pub fn push(&mut self, mut layer: Box<dyn Component>) { let size = self.size(); // trigger required_size on init |