cursor fixed
This commit is contained in:
@@ -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};
|
||||
@@ -72,6 +72,14 @@ impl TerminalCore {
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn hide_cursor(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
execute!(
|
||||
self.terminal.backend_mut(),
|
||||
Hide
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TerminalCore {
|
||||
|
||||
@@ -75,14 +75,21 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
if !app_state.ui.focus_outside_canvas {
|
||||
terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?;
|
||||
} else {
|
||||
terminal
|
||||
.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
|
||||
terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
|
||||
}
|
||||
terminal.show_cursor()?; // Ensure visible
|
||||
terminal.show_cursor()?;
|
||||
}
|
||||
AppMode::General | AppMode::Command => {
|
||||
AppMode::General => {
|
||||
if app_state.ui.focus_outside_canvas {
|
||||
terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
|
||||
terminal.show_cursor()?;
|
||||
} else {
|
||||
terminal.hide_cursor()?;
|
||||
}
|
||||
}
|
||||
AppMode::Command => {
|
||||
terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
|
||||
terminal.show_cursor()?; // Ensure visible (though might not be positioned meaningfully)
|
||||
terminal.show_cursor()?;
|
||||
}
|
||||
}
|
||||
// --- End Cursor Visibility Logic ---
|
||||
|
||||
Reference in New Issue
Block a user