read only mode needs adjustement to 4 fields from 2

This commit is contained in:
filipriec
2025-04-10 23:04:25 +02:00
parent 337d6050ff
commit 14f9b254b2
4 changed files with 17 additions and 17 deletions

View File

@@ -31,7 +31,7 @@ pub async fn handle_read_only_event(
} }
if config.is_enter_edit_mode_after(key.code, key.modifiers) { 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.get_current_input(),
auth_state.current_cursor_pos(), 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 !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); auth_state.set_current_cursor_pos(current_pos + 1);
*ideal_cursor_column = auth_state.current_cursor_pos(); *ideal_cursor_column = auth_state.current_cursor_pos();
} else { } else {
@@ -81,14 +81,14 @@ pub async fn handle_read_only_event(
ideal_cursor_column, ideal_cursor_column,
) )
.await? .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( crate::tui::functions::login::handle_action(
action, action,
auth_state, auth_state,
ideal_cursor_column, ideal_cursor_column,
) )
.await? .await?
} else if app_state.ui.show_login { } else if app_state.ui.show_login || app_state.ui.show_register{
auth_ro::execute_action( auth_ro::execute_action(
action, action,
app_state, app_state,
@@ -128,14 +128,14 @@ pub async fn handle_read_only_event(
ideal_cursor_column, ideal_cursor_column,
) )
.await? .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( crate::tui::functions::login::handle_action(
action, action,
auth_state, auth_state,
ideal_cursor_column, ideal_cursor_column,
) )
.await? .await?
} else if app_state.ui.show_login { } else if app_state.ui.show_login || app_state.ui.show_register {
auth_ro::execute_action( auth_ro::execute_action(
action, action,
app_state, app_state,
@@ -174,14 +174,14 @@ pub async fn handle_read_only_event(
ideal_cursor_column, ideal_cursor_column,
) )
.await? .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( crate::tui::functions::login::handle_action(
action, action,
auth_state, auth_state,
ideal_cursor_column, ideal_cursor_column,
) )
.await? .await?
} else if app_state.ui.show_login { } else if app_state.ui.show_login || app_state.ui.show_register {
auth_ro::execute_action( auth_ro::execute_action(
action, action,
app_state, app_state,

View File

@@ -156,19 +156,19 @@ impl EventHandler {
if config.is_enter_edit_mode_after(key_code, modifiers) && if config.is_enter_edit_mode_after(key_code, modifiers) &&
ModeManager::can_enter_edit_mode(current_mode) { 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() auth_state.get_current_input()
} else { } else {
form_state.get_current_input() 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() auth_state.current_cursor_pos()
} else { } else {
form_state.current_cursor_pos() form_state.current_cursor_pos()
}; };
if !current_input.is_empty() && current_cursor_pos < current_input.len() { 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); auth_state.set_current_cursor_pos(current_cursor_pos + 1);
self.ideal_cursor_column = auth_state.current_cursor_pos(); self.ideal_cursor_column = auth_state.current_cursor_pos();
} else { } else {
@@ -238,7 +238,7 @@ impl EventHandler {
self.is_edit_mode = false; self.is_edit_mode = false;
self.edit_mode_cooldown = true; 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() auth_state.has_unsaved_changes()
} else { } else {
form_state.has_unsaved_changes() form_state.has_unsaved_changes()
@@ -252,12 +252,12 @@ impl EventHandler {
terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?; 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() auth_state.get_current_input()
} else { } else {
form_state.get_current_input() 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() auth_state.current_cursor_pos()
} else { } else {
form_state.current_cursor_pos() form_state.current_cursor_pos()
@@ -265,7 +265,7 @@ impl EventHandler {
if !current_input.is_empty() && current_cursor_pos >= current_input.len() { if !current_input.is_empty() && current_cursor_pos >= current_input.len() {
let new_pos = current_input.len() - 1; 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); auth_state.set_current_cursor_pos(new_pos);
self.ideal_cursor_column = auth_state.current_cursor_pos(); self.ideal_cursor_column = auth_state.current_cursor_pos();
} else { } else {

View File

@@ -23,7 +23,7 @@ impl ModeManager {
return AppMode::General; 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 { if event_handler.is_edit_mode {
AppMode::Edit AppMode::Edit
} else { } else {

View File

@@ -243,7 +243,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
form_state.current_cursor_pos = form_state.current_cursor_pos =
event_handler.ideal_cursor_column.min(max_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 // Handle cursor updates for AuthState if needed, similar to FormState
if !event_handler.is_edit_mode { if !event_handler.is_edit_mode {
let current_input = auth_state.get_current_input(); let current_input = auth_state.get_current_input();