compiled
This commit is contained in:
@@ -10,7 +10,6 @@ use crate::modes::general::command_navigation::{
|
|||||||
handle_command_navigation_event, NavigationState,
|
handle_command_navigation_event, NavigationState,
|
||||||
};
|
};
|
||||||
use crate::modes::{
|
use crate::modes::{
|
||||||
canvas::{common_mode, edit, read_only},
|
|
||||||
common::{command_mode, commands::CommandHandler},
|
common::{command_mode, commands::CommandHandler},
|
||||||
general::{dialog, navigation},
|
general::{dialog, navigation},
|
||||||
handlers::mode_manager::{AppMode, ModeManager},
|
handlers::mode_manager::{AppMode, ModeManager},
|
||||||
@@ -755,18 +754,8 @@ impl EventHandler {
|
|||||||
if let Some(action) = config.get_common_action(key_code, modifiers) {
|
if let Some(action) = config.get_common_action(key_code, modifiers) {
|
||||||
match action {
|
match action {
|
||||||
"save" | "force_quit" | "save_and_quit" | "revert" => {
|
"save" | "force_quit" | "save_and_quit" | "revert" => {
|
||||||
return common_mode::handle_core_action(
|
// TODO: Replace with proper implementation
|
||||||
action,
|
return Ok(EventOutcome::Ok("Action not implemented".to_string()));
|
||||||
form_state,
|
|
||||||
auth_state,
|
|
||||||
login_state,
|
|
||||||
register_state,
|
|
||||||
&mut self.grpc_client,
|
|
||||||
&mut self.auth_client,
|
|
||||||
terminal,
|
|
||||||
app_state,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -785,25 +774,7 @@ impl EventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to legacy read-only event handling
|
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
||||||
let (_should_exit, message) = read_only::handle_read_only_event(
|
|
||||||
app_state,
|
|
||||||
key_event,
|
|
||||||
config,
|
|
||||||
form_state,
|
|
||||||
login_state,
|
|
||||||
register_state,
|
|
||||||
&mut admin_state.add_table_state,
|
|
||||||
&mut admin_state.add_logic_state,
|
|
||||||
&mut self.key_sequence_tracker,
|
|
||||||
&mut self.grpc_client,
|
|
||||||
&mut self.command_message,
|
|
||||||
&mut self.edit_mode_cooldown,
|
|
||||||
&mut self.ideal_cursor_column,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
return Ok(EventOutcome::Ok(message));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppMode::Highlight => {
|
AppMode::Highlight => {
|
||||||
@@ -821,24 +792,7 @@ impl EventHandler {
|
|||||||
return Ok(EventOutcome::Ok("".to_string()));
|
return Ok(EventOutcome::Ok("".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let (_should_exit, message) =
|
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
||||||
read_only::handle_read_only_event(
|
|
||||||
app_state,
|
|
||||||
key_event,
|
|
||||||
config,
|
|
||||||
form_state,
|
|
||||||
login_state,
|
|
||||||
register_state,
|
|
||||||
&mut admin_state.add_table_state,
|
|
||||||
&mut admin_state.add_logic_state,
|
|
||||||
&mut self.key_sequence_tracker,
|
|
||||||
&mut self.grpc_client,
|
|
||||||
&mut self.command_message,
|
|
||||||
&mut self.edit_mode_cooldown,
|
|
||||||
&mut self.ideal_cursor_column,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
return Ok(EventOutcome::Ok(message));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppMode::Edit => {
|
AppMode::Edit => {
|
||||||
@@ -846,18 +800,8 @@ impl EventHandler {
|
|||||||
if let Some(action) = config.get_common_action(key_code, modifiers) {
|
if let Some(action) = config.get_common_action(key_code, modifiers) {
|
||||||
match action {
|
match action {
|
||||||
"save" | "force_quit" | "save_and_quit" | "revert" => {
|
"save" | "force_quit" | "save_and_quit" | "revert" => {
|
||||||
return common_mode::handle_core_action(
|
// TODO: Replace with proper implementation
|
||||||
action,
|
return Ok(EventOutcome::Ok("Action not implemented".to_string()));
|
||||||
form_state,
|
|
||||||
auth_state,
|
|
||||||
login_state,
|
|
||||||
register_state,
|
|
||||||
&mut self.grpc_client,
|
|
||||||
&mut self.auth_client,
|
|
||||||
terminal,
|
|
||||||
app_state,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -879,90 +823,9 @@ impl EventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle legacy edit events
|
|
||||||
let mut current_position = form_state.current_position;
|
|
||||||
let total_count = form_state.total_count;
|
|
||||||
|
|
||||||
let edit_result = edit::handle_edit_event(
|
|
||||||
key_event,
|
|
||||||
config,
|
|
||||||
form_state,
|
|
||||||
login_state,
|
|
||||||
register_state,
|
|
||||||
admin_state,
|
|
||||||
&mut current_position,
|
|
||||||
total_count,
|
|
||||||
self,
|
|
||||||
app_state,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
match edit_result {
|
|
||||||
Ok(edit::EditEventOutcome::ExitEditMode) => {
|
|
||||||
self.is_edit_mode = false;
|
|
||||||
self.edit_mode_cooldown = true;
|
|
||||||
|
|
||||||
// Check for unsaved changes across all states
|
|
||||||
let has_changes = Self::get_has_unsaved_changes_for_state(
|
|
||||||
app_state,
|
|
||||||
login_state,
|
|
||||||
register_state,
|
|
||||||
form_state
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set appropriate message based on changes
|
|
||||||
self.command_message = if has_changes {
|
|
||||||
"Exited edit mode (unsaved changes remain)".to_string()
|
|
||||||
} else {
|
|
||||||
"Read-only mode".to_string()
|
|
||||||
};
|
|
||||||
|
|
||||||
terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?;
|
|
||||||
|
|
||||||
// Get current input and cursor position
|
|
||||||
let current_input = Self::get_current_input_for_state(
|
|
||||||
app_state,
|
|
||||||
login_state,
|
|
||||||
register_state,
|
|
||||||
form_state
|
|
||||||
);
|
|
||||||
let current_cursor_pos = Self::get_current_cursor_pos_for_state(
|
|
||||||
app_state,
|
|
||||||
login_state,
|
|
||||||
register_state,
|
|
||||||
form_state
|
|
||||||
);
|
|
||||||
|
|
||||||
// Adjust cursor if it's beyond the input length
|
|
||||||
if !current_input.is_empty() && current_cursor_pos >= current_input.len() {
|
|
||||||
let new_pos = current_input.len() - 1;
|
|
||||||
Self::set_current_cursor_pos_for_state(
|
|
||||||
app_state,
|
|
||||||
login_state,
|
|
||||||
register_state,
|
|
||||||
form_state,
|
|
||||||
new_pos
|
|
||||||
);
|
|
||||||
self.ideal_cursor_column = new_pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(edit::EditEventOutcome::Message(msg)) => {
|
|
||||||
if !msg.is_empty() {
|
|
||||||
self.command_message = msg;
|
|
||||||
}
|
|
||||||
self.key_sequence_tracker.reset();
|
|
||||||
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(e) => {
|
|
||||||
return Err(e.into());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AppMode::Command => {
|
AppMode::Command => {
|
||||||
if config.is_exit_command_mode(key_code, modifiers) {
|
if config.is_exit_command_mode(key_code, modifiers) {
|
||||||
self.command_input.clear();
|
self.command_input.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user