modes needs more progress
This commit is contained in:
@@ -35,7 +35,7 @@ next_entry = ["right","1"]
|
||||
|
||||
move_left = ["h"]
|
||||
move_right = ["l"]
|
||||
move_up = ["k", "Up"]
|
||||
move_up = ["k"]
|
||||
move_down = ["j"]
|
||||
move_word_next = ["w"]
|
||||
move_word_end = ["e"]
|
||||
|
||||
@@ -113,25 +113,31 @@ impl EventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle common actions
|
||||
// Check for core application actions (save, quit, etc.)
|
||||
// ONLY handle a limited subset of core actions here
|
||||
if let Some(action) = config.get_action_for_key_in_mode(
|
||||
&config.keybindings.common,
|
||||
key_code,
|
||||
modifiers
|
||||
) {
|
||||
return self.handle_common_action(
|
||||
action,
|
||||
form_state,
|
||||
grpc_client,
|
||||
command_handler,
|
||||
terminal,
|
||||
app_state,
|
||||
current_position,
|
||||
total_count,
|
||||
).await;
|
||||
match action {
|
||||
"save" | "force_quit" | "save_and_quit" | "revert" => {
|
||||
return self.handle_core_action(
|
||||
action,
|
||||
form_state,
|
||||
grpc_client,
|
||||
command_handler,
|
||||
terminal,
|
||||
app_state,
|
||||
current_position,
|
||||
total_count,
|
||||
).await;
|
||||
},
|
||||
_ => {} // For other actions, let the mode-specific handler take care of it
|
||||
}
|
||||
}
|
||||
|
||||
// Handle read-only mode specific actions
|
||||
// Let read_only mode handle its own actions (including navigation from common bindings)
|
||||
return read_only::handle_read_only_event(
|
||||
key,
|
||||
config,
|
||||
@@ -166,25 +172,31 @@ impl EventHandler {
|
||||
return Ok((false, self.command_message.clone()));
|
||||
}
|
||||
|
||||
// Handle common actions
|
||||
// Check for core application actions (save, quit, etc.)
|
||||
// ONLY handle a limited subset of core actions here
|
||||
if let Some(action) = config.get_action_for_key_in_mode(
|
||||
&config.keybindings.common,
|
||||
key_code,
|
||||
modifiers
|
||||
) {
|
||||
return self.handle_common_action(
|
||||
action,
|
||||
form_state,
|
||||
grpc_client,
|
||||
command_handler,
|
||||
terminal,
|
||||
app_state,
|
||||
current_position,
|
||||
total_count,
|
||||
).await;
|
||||
match action {
|
||||
"save" | "force_quit" | "save_and_quit" | "revert" => {
|
||||
return self.handle_core_action(
|
||||
action,
|
||||
form_state,
|
||||
grpc_client,
|
||||
command_handler,
|
||||
terminal,
|
||||
app_state,
|
||||
current_position,
|
||||
total_count,
|
||||
).await;
|
||||
},
|
||||
_ => {} // For other actions, let the mode-specific handler take care of it
|
||||
}
|
||||
}
|
||||
|
||||
// Handle edit mode actions
|
||||
// Let edit mode handle its own actions (including navigation from common bindings)
|
||||
let result = edit::handle_edit_event_internal(
|
||||
key,
|
||||
config,
|
||||
@@ -287,8 +299,8 @@ impl EventHandler {
|
||||
Ok((false, String::new()))
|
||||
}
|
||||
|
||||
// Helper method for handling common actions across modes
|
||||
async fn handle_common_action(
|
||||
// Helper method for handling core application actions (not navigation)
|
||||
async fn handle_core_action(
|
||||
&mut self,
|
||||
action: &str,
|
||||
form_state: &mut FormState,
|
||||
@@ -327,39 +339,8 @@ impl EventHandler {
|
||||
).await?;
|
||||
Ok((false, message))
|
||||
},
|
||||
"move_up" => {
|
||||
if form_state.current_field == 0 {
|
||||
form_state.current_field = form_state.fields.len() - 1;
|
||||
} else {
|
||||
form_state.current_field = form_state.current_field.saturating_sub(1);
|
||||
}
|
||||
let current_input = form_state.get_current_input();
|
||||
let max_cursor_pos = if !current_input.is_empty() {
|
||||
current_input.len() - 1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
form_state.current_cursor_pos = self.ideal_cursor_column.min(max_cursor_pos);
|
||||
Ok((false, String::new()))
|
||||
},
|
||||
"move_down" => {
|
||||
form_state.current_field = (form_state.current_field + 1) % form_state.fields.len();
|
||||
let current_input = form_state.get_current_input();
|
||||
let max_cursor_pos = if !current_input.is_empty() {
|
||||
current_input.len() - 1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
form_state.current_cursor_pos = self.ideal_cursor_column.min(max_cursor_pos);
|
||||
Ok((false, String::new()))
|
||||
},
|
||||
"toggle_sidebar" => {
|
||||
navigation::toggle_sidebar(app_state);
|
||||
Ok((false, format!("Sidebar {}",
|
||||
if app_state.ui.show_sidebar { "shown" } else { "hidden" }
|
||||
)))
|
||||
},
|
||||
_ => Ok((false, format!("Unknown common action: {}", action))),
|
||||
// We should never hit this case given our filtering above
|
||||
_ => Ok((false, format!("Core action not handled: {}", action))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user