cursor hidden if not active

This commit is contained in:
filipriec
2025-04-07 17:16:36 +02:00
parent b061dd3395
commit 7830ebdb3b
2 changed files with 40 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
use crossterm::{
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
cursor::{SetCursorStyle, EnableBlinking, Show, MoveTo},
cursor::{SetCursorStyle, EnableBlinking, Show, Hide, MoveTo},
};
use ratatui::{backend::CrosstermBackend, Terminal};
use std::io::{self, stdout, Write};
@@ -64,6 +64,22 @@ impl TerminalCore {
)?;
Ok(())
}
pub fn show_cursor(&mut self) -> Result<(), Box<dyn std::error::Error>> {
execute!(
self.terminal.backend_mut(),
Show
)?;
Ok(())
}
pub fn hide_cursor(&mut self) -> Result<(), Box<dyn std::error::Error>> {
execute!(
self.terminal.backend_mut(),
Hide
)?;
Ok(())
}
}
impl Drop for TerminalCore {