better and better
This commit is contained in:
@@ -110,7 +110,7 @@ impl EventHandler {
|
||||
total_count: u64,
|
||||
current_position: &mut u64,
|
||||
) -> Result<EventOutcome> {
|
||||
let current_mode = ModeManager::derive_mode(app_state, self);
|
||||
let current_mode = ModeManager::derive_mode(app_state, self, admin_state);
|
||||
app_state.update_mode(current_mode);
|
||||
|
||||
let current_view = {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// src/modes/handlers/mode_manager.rs
|
||||
use crate::state::app::state::AppState;
|
||||
use crate::modes::handlers::event::EventHandler;
|
||||
use crate::state::pages::add_logic::AddLogicFocus;
|
||||
use crate::state::app::highlight::HighlightState;
|
||||
use crate::state::pages::admin::AdminState;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum AppMode {
|
||||
@@ -16,7 +18,11 @@ pub struct ModeManager;
|
||||
|
||||
impl ModeManager {
|
||||
// Determine current mode based on app state
|
||||
pub fn derive_mode(app_state: &AppState, event_handler: &EventHandler) -> AppMode {
|
||||
pub fn derive_mode(
|
||||
app_state: &AppState,
|
||||
event_handler: &EventHandler,
|
||||
admin_state: &AdminState,
|
||||
) -> AppMode {
|
||||
if event_handler.command_mode {
|
||||
return AppMode::Command;
|
||||
}
|
||||
@@ -25,16 +31,38 @@ impl ModeManager {
|
||||
return AppMode::Highlight;
|
||||
}
|
||||
|
||||
if app_state.ui.focus_outside_canvas {
|
||||
return AppMode::General;
|
||||
}
|
||||
|
||||
let is_canvas_view = app_state.ui.show_login
|
||||
|| app_state.ui.show_register
|
||||
|| app_state.ui.show_form
|
||||
|| app_state.ui.show_add_table;
|
||||
|| app_state.ui.show_add_table
|
||||
|| app_state.ui.show_add_logic;
|
||||
|
||||
if is_canvas_view {
|
||||
if app_state.ui.show_add_logic {
|
||||
// Specific logic for AddLogic view
|
||||
match admin_state.add_logic_state.current_focus {
|
||||
AddLogicFocus::InputLogicName
|
||||
| AddLogicFocus::InputTargetColumn
|
||||
| AddLogicFocus::InputDescription => {
|
||||
// These are canvas inputs
|
||||
if event_handler.is_edit_mode {
|
||||
AppMode::Edit
|
||||
} else {
|
||||
AppMode::ReadOnly
|
||||
}
|
||||
}
|
||||
_ => AppMode::General,
|
||||
}
|
||||
} else if app_state.ui.show_add_table {
|
||||
if app_state.ui.focus_outside_canvas {
|
||||
AppMode::General
|
||||
} else {
|
||||
if event_handler.is_edit_mode {
|
||||
AppMode::Edit
|
||||
} else {
|
||||
AppMode::ReadOnly
|
||||
}
|
||||
}
|
||||
} else if is_canvas_view {
|
||||
if app_state.ui.focus_outside_canvas {
|
||||
AppMode::General
|
||||
} else {
|
||||
|
||||
@@ -155,7 +155,7 @@ pub async fn run_ui() -> Result<()> {
|
||||
|
||||
// --- Cursor Visibility Logic ---
|
||||
// (Keep existing cursor logic here - depends on state drawn above)
|
||||
let current_mode = ModeManager::derive_mode(&app_state, &event_handler);
|
||||
let current_mode = ModeManager::derive_mode(&app_state, &event_handler, &admin_state);
|
||||
match current_mode {
|
||||
AppMode::Edit => { terminal.show_cursor()?; }
|
||||
AppMode::Highlight => { terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?; terminal.show_cursor()?; }
|
||||
|
||||
Reference in New Issue
Block a user