diff --git a/client/src/functions/modes/read_only/auth_ro.rs b/client/src/functions/modes/read_only/auth_ro.rs index dd51cec..9879557 100644 --- a/client/src/functions/modes/read_only/auth_ro.rs +++ b/client/src/functions/modes/read_only/auth_ro.rs @@ -26,6 +26,86 @@ pub async fn execute_action( action )) } + "move_up" => { + key_sequence_tracker.reset(); + let num_fields = state.fields().len(); + if num_fields == 0 { + return Ok("No fields to navigate.".to_string()); + } + let current_field = state.current_field(); + let new_field = if current_field == 0 { + num_fields - 1 + } else { + current_field - 1 + }; + state.set_current_field(new_field); + let current_input = state.get_current_input(); + let max_cursor_pos = if current_input.is_empty() { + 0 + } else { + current_input.len().saturating_sub(1) + }; + let new_pos = (*ideal_cursor_column).min(max_cursor_pos); + state.set_current_cursor_pos(new_pos); + + Ok("move up from functions/modes/read_only/auth_ro.rs".to_string()) + } + "move_down" => { + key_sequence_tracker.reset(); + let num_fields = state.fields().len(); + if num_fields == 0 { + return Ok("No fields to navigate.".to_string()); + } + let current_field = state.current_field(); + let new_field = (current_field + 1) % num_fields; + state.set_current_field(new_field); + let current_input = state.get_current_input(); + let max_cursor_pos = if current_input.is_empty() { + 0 + } else { + current_input.len().saturating_sub(1) + }; + let new_pos = (*ideal_cursor_column).min(max_cursor_pos); + state.set_current_cursor_pos(new_pos); + Ok("move down from functions/modes/read_only/auth_ro.rs".to_string()) + } + "move_first_line" => { + key_sequence_tracker.reset(); + let num_fields = state.fields().len(); + if num_fields == 0 { + return Ok("No fields to navigate to.".to_string()); + } + state.set_current_field(0); + let current_input = state.get_current_input(); + let max_cursor_pos = if current_input.is_empty() { + 0 + } else { + current_input.len().saturating_sub(1) + }; + let new_pos = (*ideal_cursor_column).min(max_cursor_pos); + state.set_current_cursor_pos(new_pos); + *ideal_cursor_column = new_pos; + Ok("".to_string()) + } + "move_last_line" => { + key_sequence_tracker.reset(); + let num_fields = state.fields().len(); + if num_fields == 0 { + return Ok("No fields to navigate to.".to_string()); + } + let last_field_index = num_fields - 1; + state.set_current_field(last_field_index); + let current_input = state.get_current_input(); + let max_cursor_pos = if current_input.is_empty() { + 0 + } else { + current_input.len().saturating_sub(1) + }; + let new_pos = (*ideal_cursor_column).min(max_cursor_pos); + state.set_current_cursor_pos(new_pos); + *ideal_cursor_column = new_pos; + Ok("".to_string()) + } "exit_edit_mode" => { key_sequence_tracker.reset(); command_message.clear();