switching now execute action functions left to right
This commit is contained in:
@@ -1,47 +1,8 @@
|
|||||||
// src/functions/modes/read_only/auth_fun.rs
|
// src/functions/modes/read_only/auth_ro.rs
|
||||||
|
|
||||||
use crate::config::binds::key_sequences::KeySequenceTracker;
|
use crate::config::binds::key_sequences::KeySequenceTracker;
|
||||||
use crate::state::canvas_state::CanvasState;
|
use crate::state::canvas_state::CanvasState;
|
||||||
use crate::state::pages::auth::AuthState;
|
use std::error::Error;
|
||||||
|
|
||||||
// --- Context-Specific Actions Handled Here ---
|
|
||||||
const CONTEXT_ACTIONS_LOGIN: &[&str] = &[
|
|
||||||
"move_up",
|
|
||||||
"move_down",
|
|
||||||
"move_first_line",
|
|
||||||
"move_last_line",
|
|
||||||
];
|
|
||||||
|
|
||||||
pub async fn handle_action(
|
|
||||||
action: &str,
|
|
||||||
auth_state: &mut AuthState,
|
|
||||||
ideal_cursor_column: &mut usize,
|
|
||||||
key_sequence_tracker: &mut KeySequenceTracker,
|
|
||||||
command_message: &mut String,
|
|
||||||
) -> Result<String, Box<dyn std::error::Error>> {
|
|
||||||
if CONTEXT_ACTIONS_LOGIN.contains(&action) {
|
|
||||||
// Delegate context-specific actions to the original handler
|
|
||||||
// (or implement the logic directly here if preferred)
|
|
||||||
crate::tui::functions::login::handle_action(
|
|
||||||
action,
|
|
||||||
auth_state,
|
|
||||||
ideal_cursor_column,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
} else {
|
|
||||||
// Handle generic actions using the local execute_action
|
|
||||||
execute_action(
|
|
||||||
action,
|
|
||||||
auth_state,
|
|
||||||
ideal_cursor_column,
|
|
||||||
key_sequence_tracker,
|
|
||||||
command_message,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Generic Action Implementation (Copied and made private) ---
|
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
enum CharType {
|
enum CharType {
|
||||||
@@ -50,27 +11,22 @@ enum CharType {
|
|||||||
Punctuation,
|
Punctuation,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn execute_action<S: CanvasState>(
|
pub async fn execute_action<S: CanvasState>(
|
||||||
action: &str,
|
action: &str,
|
||||||
state: &mut S,
|
state: &mut S,
|
||||||
ideal_cursor_column: &mut usize,
|
ideal_cursor_column: &mut usize,
|
||||||
key_sequence_tracker: &mut KeySequenceTracker,
|
key_sequence_tracker: &mut KeySequenceTracker,
|
||||||
command_message: &mut String,
|
command_message: &mut String,
|
||||||
) -> Result<String, Box<dyn std::error::Error>> {
|
) -> Result<String, Box<dyn Error>> {
|
||||||
match action {
|
match action {
|
||||||
// Context actions are handled above
|
"previous_entry" | "next_entry" | "move_up" | "move_down" |
|
||||||
"move_up" | "move_down" | "move_first_line" | "move_last_line" => {
|
"move_first_line" | "move_last_line" => {
|
||||||
key_sequence_tracker.reset();
|
key_sequence_tracker.reset();
|
||||||
Ok(format!(
|
Ok(format!(
|
||||||
"Action '{}' should be handled by context-specific logic",
|
"Action '{}' should be handled by context-specific logic",
|
||||||
action
|
action
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
// These form-specific actions don't apply to login
|
|
||||||
"previous_entry" | "next_entry" => {
|
|
||||||
key_sequence_tracker.reset();
|
|
||||||
Ok(format!("Action '{}' not applicable in login context", action))
|
|
||||||
}
|
|
||||||
"exit_edit_mode" => {
|
"exit_edit_mode" => {
|
||||||
key_sequence_tracker.reset();
|
key_sequence_tracker.reset();
|
||||||
command_message.clear();
|
command_message.clear();
|
||||||
@@ -86,20 +42,13 @@ async fn execute_action<S: CanvasState>(
|
|||||||
"move_right" => {
|
"move_right" => {
|
||||||
let current_input = state.get_current_input();
|
let current_input = state.get_current_input();
|
||||||
let current_pos = state.current_cursor_pos();
|
let current_pos = state.current_cursor_pos();
|
||||||
// Login fields often allow cursor at the very end for appending
|
if !current_input.is_empty()
|
||||||
if current_pos < current_input.len() {
|
&& current_pos < current_input.len().saturating_sub(1)
|
||||||
|
{
|
||||||
let new_pos = current_pos + 1;
|
let new_pos = current_pos + 1;
|
||||||
state.set_current_cursor_pos(new_pos);
|
state.set_current_cursor_pos(new_pos);
|
||||||
*ideal_cursor_column = new_pos;
|
*ideal_cursor_column = new_pos;
|
||||||
}
|
}
|
||||||
// Original logic (prevents going one past the end):
|
|
||||||
// if !current_input.is_empty()
|
|
||||||
// && current_pos < current_input.len().saturating_sub(1)
|
|
||||||
// {
|
|
||||||
// let new_pos = current_pos + 1;
|
|
||||||
// state.set_current_cursor_pos(new_pos);
|
|
||||||
// *ideal_cursor_column = new_pos;
|
|
||||||
// }
|
|
||||||
Ok("".to_string())
|
Ok("".to_string())
|
||||||
}
|
}
|
||||||
"move_word_next" => {
|
"move_word_next" => {
|
||||||
@@ -107,10 +56,7 @@ async fn execute_action<S: CanvasState>(
|
|||||||
if !current_input.is_empty() {
|
if !current_input.is_empty() {
|
||||||
let new_pos =
|
let new_pos =
|
||||||
find_next_word_start(current_input, state.current_cursor_pos());
|
find_next_word_start(current_input, state.current_cursor_pos());
|
||||||
// Allow cursor at end for login fields
|
let final_pos = new_pos.min(current_input.len().saturating_sub(1));
|
||||||
let final_pos = new_pos.min(current_input.len());
|
|
||||||
// Original:
|
|
||||||
// let final_pos = new_pos.min(current_input.len().saturating_sub(1));
|
|
||||||
state.set_current_cursor_pos(final_pos);
|
state.set_current_cursor_pos(final_pos);
|
||||||
*ideal_cursor_column = final_pos;
|
*ideal_cursor_column = final_pos;
|
||||||
}
|
}
|
||||||
@@ -128,10 +74,7 @@ async fn execute_action<S: CanvasState>(
|
|||||||
find_word_end(current_input, new_pos + 1)
|
find_word_end(current_input, new_pos + 1)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Allow cursor at end for login fields
|
let max_valid_index = current_input.len().saturating_sub(1);
|
||||||
let max_valid_index = current_input.len();
|
|
||||||
// Original:
|
|
||||||
// let max_valid_index = current_input.len().saturating_sub(1);
|
|
||||||
let clamped_pos = final_pos.min(max_valid_index);
|
let clamped_pos = final_pos.min(max_valid_index);
|
||||||
state.set_current_cursor_pos(clamped_pos);
|
state.set_current_cursor_pos(clamped_pos);
|
||||||
*ideal_cursor_column = clamped_pos;
|
*ideal_cursor_column = clamped_pos;
|
||||||
@@ -160,7 +103,7 @@ async fn execute_action<S: CanvasState>(
|
|||||||
state.set_current_cursor_pos(new_pos);
|
state.set_current_cursor_pos(new_pos);
|
||||||
*ideal_cursor_column = new_pos;
|
*ideal_cursor_column = new_pos;
|
||||||
}
|
}
|
||||||
Ok("".to_string()) // Maybe clear msg?
|
Ok("Moved to previous word end".to_string())
|
||||||
}
|
}
|
||||||
"move_line_start" => {
|
"move_line_start" => {
|
||||||
state.set_current_cursor_pos(0);
|
state.set_current_cursor_pos(0);
|
||||||
@@ -169,29 +112,23 @@ async fn execute_action<S: CanvasState>(
|
|||||||
}
|
}
|
||||||
"move_line_end" => {
|
"move_line_end" => {
|
||||||
let current_input = state.get_current_input();
|
let current_input = state.get_current_input();
|
||||||
// Allow cursor at end for login fields
|
if !current_input.is_empty() {
|
||||||
let new_pos = current_input.len();
|
let new_pos = current_input.len().saturating_sub(1);
|
||||||
// Original:
|
|
||||||
// if !current_input.is_empty() {
|
|
||||||
// let new_pos = current_input.len().saturating_sub(1);
|
|
||||||
// state.set_current_cursor_pos(new_pos);
|
|
||||||
// *ideal_cursor_column = new_pos;
|
|
||||||
// } else {
|
|
||||||
// state.set_current_cursor_pos(0);
|
|
||||||
// *ideal_cursor_column = 0;
|
|
||||||
// }
|
|
||||||
state.set_current_cursor_pos(new_pos);
|
state.set_current_cursor_pos(new_pos);
|
||||||
*ideal_cursor_column = new_pos;
|
*ideal_cursor_column = new_pos;
|
||||||
|
} else {
|
||||||
|
state.set_current_cursor_pos(0);
|
||||||
|
*ideal_cursor_column = 0;
|
||||||
|
}
|
||||||
Ok("".to_string())
|
Ok("".to_string())
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
key_sequence_tracker.reset();
|
key_sequence_tracker.reset();
|
||||||
Ok(format!("Unknown read-only action: {}", action))
|
Ok(format!("Unknown read-only action: {}", action))
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn get_char_type(c: char) -> CharType {
|
fn get_char_type(c: char) -> CharType {
|
||||||
if c.is_whitespace() {
|
if c.is_whitespace() {
|
||||||
CharType::Whitespace
|
CharType::Whitespace
|
||||||
@@ -202,91 +139,141 @@ fn get_char_type(c: char) -> CharType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- (Copy all find_* helper functions here too) ---
|
|
||||||
fn find_next_word_start(text: &str, current_pos: usize) -> usize {
|
fn find_next_word_start(text: &str, current_pos: usize) -> usize {
|
||||||
let chars: Vec<char> = text.chars().collect();
|
let chars: Vec<char> = text.chars().collect();
|
||||||
if chars.is_empty() { return 0; }
|
if chars.is_empty() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
let current_pos = current_pos.min(chars.len());
|
let current_pos = current_pos.min(chars.len());
|
||||||
if current_pos == chars.len() { return current_pos; }
|
|
||||||
|
if current_pos == chars.len() {
|
||||||
|
return current_pos;
|
||||||
|
}
|
||||||
|
|
||||||
let mut pos = current_pos;
|
let mut pos = current_pos;
|
||||||
let initial_type = get_char_type(chars[pos]);
|
let initial_type = get_char_type(chars[pos]);
|
||||||
while pos < chars.len() && get_char_type(chars[pos]) == initial_type { pos += 1; }
|
|
||||||
while pos < chars.len() && get_char_type(chars[pos]) == CharType::Whitespace { pos += 1; }
|
while pos < chars.len() && get_char_type(chars[pos]) == initial_type {
|
||||||
|
pos += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while pos < chars.len() && get_char_type(chars[pos]) == CharType::Whitespace {
|
||||||
|
pos += 1;
|
||||||
|
}
|
||||||
|
|
||||||
pos
|
pos
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_next_word_end(text: &str, current_pos: usize) -> usize {
|
fn find_next_word_end(text: &str, current_pos: usize) -> usize {
|
||||||
let chars: Vec<char> = text.chars().collect();
|
let chars: Vec<char> = text.chars().collect();
|
||||||
if chars.is_empty() { return 0; }
|
if chars.is_empty() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
let next_start = find_next_word_start(text, current_pos);
|
let next_start = find_next_word_start(text, current_pos);
|
||||||
// Allow end position for login
|
|
||||||
if next_start >= chars.len() { return chars.len(); }
|
if next_start >= chars.len() {
|
||||||
// Original: if next_start >= chars.len() { return chars.len().saturating_sub(1); }
|
return chars.len().saturating_sub(1);
|
||||||
|
}
|
||||||
|
|
||||||
let mut pos = next_start;
|
let mut pos = next_start;
|
||||||
let word_type = get_char_type(chars[pos]);
|
let word_type = get_char_type(chars[pos]);
|
||||||
while pos < chars.len() && get_char_type(chars[pos]) == word_type { pos += 1; }
|
|
||||||
// Allow end position for login
|
while pos < chars.len() && get_char_type(chars[pos]) == word_type {
|
||||||
pos.min(chars.len())
|
pos += 1;
|
||||||
// Original: pos.saturating_sub(1).min(chars.len().saturating_sub(1))
|
}
|
||||||
|
|
||||||
|
pos.saturating_sub(1).min(chars.len().saturating_sub(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_word_end(text: &str, current_pos: usize) -> usize {
|
fn find_word_end(text: &str, current_pos: usize) -> usize {
|
||||||
let chars: Vec<char> = text.chars().collect();
|
let chars: Vec<char> = text.chars().collect();
|
||||||
let len = chars.len();
|
let len = chars.len();
|
||||||
if len == 0 { return 0; }
|
if len == 0 {
|
||||||
// Allow end position for login
|
return 0;
|
||||||
let mut pos = current_pos.min(len);
|
}
|
||||||
// Original: let mut pos = current_pos.min(len.saturating_sub(1));
|
|
||||||
// Handle case where cursor is already at the end
|
let mut pos = current_pos.min(len - 1);
|
||||||
if pos == len { return len; }
|
let original_pos = pos;
|
||||||
|
|
||||||
let current_type = get_char_type(chars[pos]);
|
let current_type = get_char_type(chars[pos]);
|
||||||
if current_type != CharType::Whitespace {
|
if current_type != CharType::Whitespace {
|
||||||
while pos < len && get_char_type(chars[pos]) == current_type { pos += 1; }
|
while pos < len && get_char_type(chars[pos]) == current_type {
|
||||||
// Allow end position for login
|
pos += 1;
|
||||||
return pos;
|
|
||||||
// Original: return pos.saturating_sub(1);
|
|
||||||
}
|
}
|
||||||
|
return pos.saturating_sub(1);
|
||||||
|
}
|
||||||
|
|
||||||
pos = find_next_word_start(text, pos);
|
pos = find_next_word_start(text, pos);
|
||||||
// Allow end position for login
|
if pos >= len {
|
||||||
if pos >= len { return len; }
|
return len.saturating_sub(1);
|
||||||
// Original: if pos >= len { return len.saturating_sub(1); }
|
}
|
||||||
|
|
||||||
let word_type = get_char_type(chars[pos]);
|
let word_type = get_char_type(chars[pos]);
|
||||||
while pos < len && get_char_type(chars[pos]) == word_type { pos += 1; }
|
while pos < len && get_char_type(chars[pos]) == word_type {
|
||||||
// Allow end position for login
|
pos += 1;
|
||||||
pos.min(len)
|
}
|
||||||
// Original: pos.saturating_sub(1).min(len.saturating_sub(1))
|
|
||||||
|
pos.saturating_sub(1).min(len.saturating_sub(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_prev_word_start(text: &str, current_pos: usize) -> usize {
|
fn find_prev_word_start(text: &str, current_pos: usize) -> usize {
|
||||||
let chars: Vec<char> = text.chars().collect();
|
let chars: Vec<char> = text.chars().collect();
|
||||||
if chars.is_empty() || current_pos == 0 { return 0; }
|
if chars.is_empty() || current_pos == 0 {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
let mut pos = current_pos.saturating_sub(1);
|
let mut pos = current_pos.saturating_sub(1);
|
||||||
while pos > 0 && get_char_type(chars[pos]) == CharType::Whitespace { pos -= 1; }
|
|
||||||
|
while pos > 0 && get_char_type(chars[pos]) == CharType::Whitespace {
|
||||||
|
pos -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
if get_char_type(chars[pos]) != CharType::Whitespace {
|
if get_char_type(chars[pos]) != CharType::Whitespace {
|
||||||
let word_type = get_char_type(chars[pos]);
|
let word_type = get_char_type(chars[pos]);
|
||||||
while pos > 0 && get_char_type(chars[pos - 1]) == word_type { pos -= 1; }
|
while pos > 0 && get_char_type(chars[pos - 1]) == word_type {
|
||||||
|
pos -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if pos == 0 && get_char_type(chars[0]) == CharType::Whitespace {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
pos
|
||||||
}
|
}
|
||||||
if pos == 0 && get_char_type(chars[0]) == CharType::Whitespace { 0 } else { pos }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_prev_word_end(text: &str, current_pos: usize) -> usize {
|
fn find_prev_word_end(text: &str, current_pos: usize) -> usize {
|
||||||
let chars: Vec<char> = text.chars().collect();
|
let chars: Vec<char> = text.chars().collect();
|
||||||
if chars.is_empty() || current_pos == 0 { return 0; }
|
if chars.is_empty() || current_pos == 0 {
|
||||||
let mut pos = current_pos.saturating_sub(1);
|
return 0;
|
||||||
while pos > 0 && get_char_type(chars[pos]) == CharType::Whitespace { pos -= 1; }
|
}
|
||||||
if pos == 0 && get_char_type(chars[0]) == CharType::Whitespace { return 0; }
|
|
||||||
if pos == 0 && get_char_type(chars[0]) != CharType::Whitespace { return 0; } // End of the first word is pos 0
|
|
||||||
let word_type = get_char_type(chars[pos]);
|
|
||||||
// Find the start of the word the cursor is in or just passed
|
|
||||||
while pos > 0 && get_char_type(chars[pos - 1]) == word_type { pos -= 1; }
|
|
||||||
// Now pos is at the start of that word. We need the end of the *previous* word.
|
|
||||||
// Skip backwards over any whitespace before this word.
|
|
||||||
while pos > 0 && get_char_type(chars[pos - 1]) == CharType::Whitespace { pos -= 1; }
|
|
||||||
// If we are at the beginning, return 0
|
|
||||||
if pos == 0 { return 0; }
|
|
||||||
// Now pos is at the end of the previous word.
|
|
||||||
pos - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let mut pos = current_pos.saturating_sub(1);
|
||||||
|
|
||||||
|
while pos > 0 && get_char_type(chars[pos]) == CharType::Whitespace {
|
||||||
|
pos -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if pos == 0 && get_char_type(chars[0]) == CharType::Whitespace {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if pos == 0 && get_char_type(chars[0]) != CharType::Whitespace {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let word_type = get_char_type(chars[pos]);
|
||||||
|
while pos > 0 && get_char_type(chars[pos - 1]) == word_type {
|
||||||
|
pos -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while pos > 0 && get_char_type(chars[pos - 1]) == CharType::Whitespace {
|
||||||
|
pos -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if pos > 0 {
|
||||||
|
pos - 1
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use crate::services::grpc_client::GrpcClient;
|
|||||||
use crate::state::canvas_state::CanvasState;
|
use crate::state::canvas_state::CanvasState;
|
||||||
use crate::state::pages::auth::AuthState;
|
use crate::state::pages::auth::AuthState;
|
||||||
use crate::state::pages::form::FormState;
|
use crate::state::pages::form::FormState;
|
||||||
use crate::functions::modes::read_only::form_ro::execute_action;
|
use crate::functions::modes::read_only::{auth_ro, form_ro};
|
||||||
use crossterm::event::KeyEvent;
|
use crossterm::event::KeyEvent;
|
||||||
|
|
||||||
pub async fn handle_read_only_event(
|
pub async fn handle_read_only_event(
|
||||||
@@ -75,8 +75,7 @@ pub async fn handle_read_only_event(
|
|||||||
key_sequence_tracker.add_key(key.code);
|
key_sequence_tracker.add_key(key.code);
|
||||||
let sequence = key_sequence_tracker.get_sequence();
|
let sequence = key_sequence_tracker.get_sequence();
|
||||||
|
|
||||||
if let Some(action) = config.matches_key_sequence_generalized(&sequence)
|
if let Some(action) = config.matches_key_sequence_generalized(&sequence) {
|
||||||
{
|
|
||||||
let result = if app_state.ui.show_form && CONTEXT_ACTIONS_FORM.contains(&action) {
|
let result = if app_state.ui.show_form && CONTEXT_ACTIONS_FORM.contains(&action) {
|
||||||
crate::tui::functions::form::handle_action(
|
crate::tui::functions::form::handle_action(
|
||||||
action,
|
action,
|
||||||
@@ -94,9 +93,8 @@ pub async fn handle_read_only_event(
|
|||||||
ideal_cursor_column,
|
ideal_cursor_column,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else if app_state.ui.show_login {
|
||||||
if app_state.ui.show_login {
|
auth_ro::execute_action(
|
||||||
execute_action(
|
|
||||||
action,
|
action,
|
||||||
auth_state,
|
auth_state,
|
||||||
ideal_cursor_column,
|
ideal_cursor_column,
|
||||||
@@ -105,7 +103,7 @@ pub async fn handle_read_only_event(
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else {
|
||||||
execute_action(
|
form_ro::execute_action(
|
||||||
action,
|
action,
|
||||||
form_state,
|
form_state,
|
||||||
ideal_cursor_column,
|
ideal_cursor_column,
|
||||||
@@ -113,7 +111,6 @@ pub async fn handle_read_only_event(
|
|||||||
command_message,
|
command_message,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
|
||||||
};
|
};
|
||||||
key_sequence_tracker.reset();
|
key_sequence_tracker.reset();
|
||||||
return Ok((false, result));
|
return Ok((false, result));
|
||||||
@@ -124,9 +121,7 @@ pub async fn handle_read_only_event(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if sequence.len() == 1 && !config.is_key_sequence_prefix(&sequence) {
|
if sequence.len() == 1 && !config.is_key_sequence_prefix(&sequence) {
|
||||||
if let Some(action) =
|
if let Some(action) = config.get_read_only_action_for_key(key.code, key.modifiers) {
|
||||||
config.get_read_only_action_for_key(key.code, key.modifiers)
|
|
||||||
{
|
|
||||||
let result = if app_state.ui.show_form && CONTEXT_ACTIONS_FORM.contains(&action) {
|
let result = if app_state.ui.show_form && CONTEXT_ACTIONS_FORM.contains(&action) {
|
||||||
crate::tui::functions::form::handle_action(
|
crate::tui::functions::form::handle_action(
|
||||||
action,
|
action,
|
||||||
@@ -144,9 +139,8 @@ pub async fn handle_read_only_event(
|
|||||||
ideal_cursor_column,
|
ideal_cursor_column,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else if app_state.ui.show_login {
|
||||||
if app_state.ui.show_login {
|
auth_ro::execute_action(
|
||||||
execute_action(
|
|
||||||
action,
|
action,
|
||||||
auth_state,
|
auth_state,
|
||||||
ideal_cursor_column,
|
ideal_cursor_column,
|
||||||
@@ -155,7 +149,7 @@ pub async fn handle_read_only_event(
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else {
|
||||||
execute_action(
|
form_ro::execute_action(
|
||||||
action,
|
action,
|
||||||
form_state,
|
form_state,
|
||||||
ideal_cursor_column,
|
ideal_cursor_column,
|
||||||
@@ -163,20 +157,16 @@ pub async fn handle_read_only_event(
|
|||||||
command_message,
|
command_message,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
|
||||||
};
|
};
|
||||||
key_sequence_tracker.reset();
|
key_sequence_tracker.reset();
|
||||||
return Ok((false, result));
|
return Ok((false, result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
key_sequence_tracker.reset();
|
key_sequence_tracker.reset();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
key_sequence_tracker.reset();
|
key_sequence_tracker.reset();
|
||||||
|
|
||||||
if let Some(action) =
|
if let Some(action) = config.get_read_only_action_for_key(key.code, key.modifiers) {
|
||||||
config.get_read_only_action_for_key(key.code, key.modifiers)
|
|
||||||
{
|
|
||||||
let result = if app_state.ui.show_form && CONTEXT_ACTIONS_FORM.contains(&action) {
|
let result = if app_state.ui.show_form && CONTEXT_ACTIONS_FORM.contains(&action) {
|
||||||
crate::tui::functions::form::handle_action(
|
crate::tui::functions::form::handle_action(
|
||||||
action,
|
action,
|
||||||
@@ -194,9 +184,8 @@ pub async fn handle_read_only_event(
|
|||||||
ideal_cursor_column,
|
ideal_cursor_column,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else if app_state.ui.show_login {
|
||||||
if app_state.ui.show_login {
|
auth_ro::execute_action(
|
||||||
execute_action(
|
|
||||||
action,
|
action,
|
||||||
auth_state,
|
auth_state,
|
||||||
ideal_cursor_column,
|
ideal_cursor_column,
|
||||||
@@ -205,7 +194,7 @@ pub async fn handle_read_only_event(
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else {
|
||||||
execute_action(
|
form_ro::execute_action(
|
||||||
action,
|
action,
|
||||||
form_state,
|
form_state,
|
||||||
ideal_cursor_column,
|
ideal_cursor_column,
|
||||||
@@ -213,7 +202,6 @@ pub async fn handle_read_only_event(
|
|||||||
command_message,
|
command_message,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return Ok((false, result));
|
return Ok((false, result));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user