cursor is disabled instead of hidden now
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, Hide, MoveTo},
|
||||
cursor::{SetCursorStyle, EnableBlinking, Show, MoveTo},
|
||||
};
|
||||
use ratatui::{backend::CrosstermBackend, Terminal};
|
||||
use std::io::{self, stdout, Write};
|
||||
@@ -72,14 +72,6 @@ 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 {
|
||||
|
||||
@@ -14,6 +14,7 @@ use crate::state::pages::auth::AuthState;
|
||||
use crate::state::canvas_state::CanvasState;
|
||||
use crate::modes::handlers::event::EventHandler;
|
||||
use crate::state::state::AppState;
|
||||
use crossterm::cursor::SetCursorStyle;
|
||||
|
||||
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = Config::load()?;
|
||||
@@ -66,20 +67,19 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let current_mode = ModeManager::derive_mode(&app_state, &event_handler);
|
||||
match current_mode {
|
||||
AppMode::Edit => {
|
||||
terminal.show_cursor()?;
|
||||
}
|
||||
AppMode::ReadOnly => {
|
||||
if !app_state.ui.focus_outside_canvas {
|
||||
terminal.show_cursor()?;
|
||||
} else {
|
||||
terminal.hide_cursor()?;
|
||||
}
|
||||
}
|
||||
AppMode::General => {
|
||||
terminal.hide_cursor()?;
|
||||
}
|
||||
AppMode::Command => {
|
||||
terminal.hide_cursor()?;
|
||||
terminal.show_cursor()?;
|
||||
}
|
||||
AppMode::ReadOnly => {
|
||||
if !app_state.ui.focus_outside_canvas {
|
||||
terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?;
|
||||
} else {
|
||||
terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
|
||||
}
|
||||
terminal.show_cursor()?; // Ensure visible
|
||||
}
|
||||
AppMode::General | AppMode::Command => {
|
||||
terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
|
||||
terminal.show_cursor()?; // Ensure visible (though might not be positioned meaningfully)
|
||||
}
|
||||
}
|
||||
// --- End Cursor Visibility Logic ---
|
||||
|
||||
Reference in New Issue
Block a user