From 14f9b254b2e5aa0ac610788e070a5349771d5238 Mon Sep 17 00:00:00 2001 From: filipriec Date: Thu, 10 Apr 2025 23:04:25 +0200 Subject: [PATCH] read only mode needs adjustement to 4 fields from 2 --- client/src/modes/canvas/read_only.rs | 16 ++++++++-------- client/src/modes/handlers/event.rs | 14 +++++++------- client/src/modes/handlers/mode_manager.rs | 2 +- client/src/ui/handlers/ui.rs | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/client/src/modes/canvas/read_only.rs b/client/src/modes/canvas/read_only.rs index 9adfa62..f9d9862 100644 --- a/client/src/modes/canvas/read_only.rs +++ b/client/src/modes/canvas/read_only.rs @@ -31,7 +31,7 @@ pub async fn handle_read_only_event( } if config.is_enter_edit_mode_after(key.code, key.modifiers) { - let (current_input, current_pos) = if app_state.ui.show_login { + let (current_input, current_pos) = if app_state.ui.show_login || app_state.ui.show_register{ ( auth_state.get_current_input(), auth_state.current_cursor_pos(), @@ -44,7 +44,7 @@ pub async fn handle_read_only_event( }; if !current_input.is_empty() && current_pos < current_input.len() { - if app_state.ui.show_login { + if app_state.ui.show_login || app_state.ui.show_register{ auth_state.set_current_cursor_pos(current_pos + 1); *ideal_cursor_column = auth_state.current_cursor_pos(); } else { @@ -81,14 +81,14 @@ pub async fn handle_read_only_event( ideal_cursor_column, ) .await? - } else if app_state.ui.show_login && CONTEXT_ACTIONS_LOGIN.contains(&action) { + } else if app_state.ui.show_login || app_state.ui.show_register && CONTEXT_ACTIONS_LOGIN.contains(&action) { crate::tui::functions::login::handle_action( action, auth_state, ideal_cursor_column, ) .await? - } else if app_state.ui.show_login { + } else if app_state.ui.show_login || app_state.ui.show_register{ auth_ro::execute_action( action, app_state, @@ -128,14 +128,14 @@ pub async fn handle_read_only_event( ideal_cursor_column, ) .await? - } else if app_state.ui.show_login && CONTEXT_ACTIONS_LOGIN.contains(&action) { + } else if app_state.ui.show_login || app_state.ui.show_register && CONTEXT_ACTIONS_LOGIN.contains(&action) { crate::tui::functions::login::handle_action( action, auth_state, ideal_cursor_column, ) .await? - } else if app_state.ui.show_login { + } else if app_state.ui.show_login || app_state.ui.show_register { auth_ro::execute_action( action, app_state, @@ -174,14 +174,14 @@ pub async fn handle_read_only_event( ideal_cursor_column, ) .await? - } else if app_state.ui.show_login && CONTEXT_ACTIONS_LOGIN.contains(&action) { + } else if app_state.ui.show_login || app_state.ui.show_register && CONTEXT_ACTIONS_LOGIN.contains(&action) { crate::tui::functions::login::handle_action( action, auth_state, ideal_cursor_column, ) .await? - } else if app_state.ui.show_login { + } else if app_state.ui.show_login || app_state.ui.show_register { auth_ro::execute_action( action, app_state, diff --git a/client/src/modes/handlers/event.rs b/client/src/modes/handlers/event.rs index 1992362..083bb04 100644 --- a/client/src/modes/handlers/event.rs +++ b/client/src/modes/handlers/event.rs @@ -156,19 +156,19 @@ impl EventHandler { if config.is_enter_edit_mode_after(key_code, modifiers) && ModeManager::can_enter_edit_mode(current_mode) { - let current_input = if app_state.ui.show_login { + let current_input = if app_state.ui.show_login || app_state.ui.show_register{ auth_state.get_current_input() } else { form_state.get_current_input() }; - let current_cursor_pos = if app_state.ui.show_login { + let current_cursor_pos = if app_state.ui.show_login || app_state.ui.show_register{ auth_state.current_cursor_pos() } else { form_state.current_cursor_pos() }; if !current_input.is_empty() && current_cursor_pos < current_input.len() { - if app_state.ui.show_login { + if app_state.ui.show_login || app_state.ui.show_register{ auth_state.set_current_cursor_pos(current_cursor_pos + 1); self.ideal_cursor_column = auth_state.current_cursor_pos(); } else { @@ -238,7 +238,7 @@ impl EventHandler { self.is_edit_mode = false; self.edit_mode_cooldown = true; - let has_changes = if app_state.ui.show_login { + let has_changes = if app_state.ui.show_login || app_state.ui.show_register{ auth_state.has_unsaved_changes() } else { form_state.has_unsaved_changes() @@ -252,12 +252,12 @@ impl EventHandler { terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?; - let current_input = if app_state.ui.show_login { + let current_input = if app_state.ui.show_login || app_state.ui.show_register{ auth_state.get_current_input() } else { form_state.get_current_input() }; - let current_cursor_pos = if app_state.ui.show_login { + let current_cursor_pos = if app_state.ui.show_login || app_state.ui.show_register{ auth_state.current_cursor_pos() } else { form_state.current_cursor_pos() @@ -265,7 +265,7 @@ impl EventHandler { if !current_input.is_empty() && current_cursor_pos >= current_input.len() { let new_pos = current_input.len() - 1; - if app_state.ui.show_login { + if app_state.ui.show_login || app_state.ui.show_register{ auth_state.set_current_cursor_pos(new_pos); self.ideal_cursor_column = auth_state.current_cursor_pos(); } else { diff --git a/client/src/modes/handlers/mode_manager.rs b/client/src/modes/handlers/mode_manager.rs index 80e0f0f..9c334bd 100644 --- a/client/src/modes/handlers/mode_manager.rs +++ b/client/src/modes/handlers/mode_manager.rs @@ -23,7 +23,7 @@ impl ModeManager { return AppMode::General; } - if app_state.ui.show_login { + if app_state.ui.show_login || app_state.ui.show_register { if event_handler.is_edit_mode { AppMode::Edit } else { diff --git a/client/src/ui/handlers/ui.rs b/client/src/ui/handlers/ui.rs index 1bbfe4d..b7dca1d 100644 --- a/client/src/ui/handlers/ui.rs +++ b/client/src/ui/handlers/ui.rs @@ -243,7 +243,7 @@ pub async fn run_ui() -> Result<(), Box> { form_state.current_cursor_pos = event_handler.ideal_cursor_column.min(max_cursor_pos); } - } else if app_state.ui.show_login { + } else if app_state.ui.show_login || app_state.ui.show_register { // Handle cursor updates for AuthState if needed, similar to FormState if !event_handler.is_edit_mode { let current_input = auth_state.get_current_input();