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