diff --git a/client/src/ui/handlers/ui.rs b/client/src/ui/handlers/ui.rs index 2b40c00..c72b144 100644 --- a/client/src/ui/handlers/ui.rs +++ b/client/src/ui/handlers/ui.rs @@ -29,6 +29,7 @@ use crate::pages::register::RegisterResult; use crate::ui::handlers::context::DialogPurpose; use crate::utils::columns::filter_user_columns; use canvas::keymap::KeyEventOutcome; +use canvas::CursorManager; use canvas::FormEditor; use anyhow::{Context, Result}; use crossterm::cursor::{SetCursorStyle, MoveTo}; @@ -699,41 +700,26 @@ pub async fn run_ui() -> Result<()> { match current_mode { AppMode::General => { if app_state.ui.focus_outside_canvas { - // General mode, focus outside canvas but canvas exists - if let Some(editor) = &app_state.form_editor { - // Get last known cursor position from canvas - let x = editor.cursor_position() as u16; - let y = editor.current_field() as u16; - - // Force underscore cursor at that position - terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?; - terminal.show_cursor()?; - - // Move cursor to last known canvas position - terminal.set_cursor_position(x, y)?; - } else { - // No canvas at all → hide cursor - terminal.hide_cursor()?; - } + // Outside canvas → app decides + terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?; + terminal.show_cursor()?; } else { - // General mode, focus inside canvas → let canvas handle cursor - // Do nothing here + // Inside canvas → let canvas handle it + if let Some(editor) = &app_state.form_editor { + let _ = CursorManager::update_for_mode(editor.mode()); + } + if let Page::Login(page) = &router.current { + let _ = CursorManager::update_for_mode(page.editor.mode()); + } + if let Page::Register(page) = &router.current { + let _ = CursorManager::update_for_mode(page.editor.mode()); + } } } AppMode::Command => { - // Command line overlay → always steady block + // Command line overlay → app decides terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?; - terminal - .show_cursor() - .context("Failed to show cursor in Command mode")?; - - // Enforce ReadOnly on any active canvases while in command mode - if let Some(editor) = &mut app_state.form_editor { - editor.set_mode(canvas::AppMode::ReadOnly); - } - if let Page::Login(page) = &mut router.current { - page.editor.set_mode(canvas::AppMode::ReadOnly); - } + terminal.show_cursor()?; } }