HUGE CHANGES TO MODESA
This commit is contained in:
@@ -49,57 +49,86 @@ impl EventHandler {
|
||||
app_state: &mut crate::state::state::AppState,
|
||||
total_count: u64,
|
||||
current_position: &mut u64,
|
||||
intro_state: &mut crate::components::intro::intro::IntroState,
|
||||
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||
if app_state.ui.show_intro {
|
||||
if let Event::Key(key) = event {
|
||||
let action = config.get_intro_action(key.code, key.modifiers);
|
||||
if let Event::Key(key) = event {
|
||||
let key_code = key.code;
|
||||
let modifiers = key.modifiers;
|
||||
|
||||
match action {
|
||||
Some("previous_option") => intro_state.previous_option(),
|
||||
Some("next_option") => intro_state.next_option(),
|
||||
Some("select") => {
|
||||
app_state.ui.show_intro = false;
|
||||
app_state.ui.show_admin = intro_state.selected_option == 1;
|
||||
},
|
||||
_ => {} // Ignore all other keys
|
||||
}
|
||||
}
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
|
||||
if let Event::Key(key) = event {
|
||||
let key_code = key.code;
|
||||
let modifiers = key.modifiers;
|
||||
|
||||
// Handle admin panel mode
|
||||
if app_state.ui.show_admin {
|
||||
if let Some(action) = config.get_admin_action(key_code, modifiers) {
|
||||
match action {
|
||||
"move_up" => {
|
||||
// Handle up movement using app_state directly
|
||||
app_state.admin_selected_item = app_state.admin_selected_item.saturating_sub(1);
|
||||
}
|
||||
"move_down" => {
|
||||
// Handle down movement using app_state
|
||||
app_state.admin_selected_item = app_state.admin_selected_item.saturating_add(1);
|
||||
}
|
||||
_ => {}
|
||||
// Handle general mode (replaces intro and admin)
|
||||
if app_state.ui.show_general_mode {
|
||||
if let Some(action) = config.get_general_action(key_code, modifiers) {
|
||||
match action {
|
||||
"move_up" => {
|
||||
app_state.general.selected_item = app_state.general.selected_item.saturating_sub(1);
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
return Ok((false, format!("Admin: {}", action)));
|
||||
"move_down" => {
|
||||
app_state.general.selected_item = app_state.general.selected_item.saturating_add(1);
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
"next_option" => {
|
||||
app_state.general.current_option = app_state.general.current_option.saturating_add(1);
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
"previous_option" => {
|
||||
app_state.general.current_option = app_state.general.current_option.saturating_sub(1);
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
"select" => {
|
||||
// Handle selection based on current view
|
||||
app_state.ui.show_general_mode = false;
|
||||
return Ok((false, "Selected".to_string()));
|
||||
}
|
||||
"toggle_sidebar" => {
|
||||
app_state.ui.show_sidebar = !app_state.ui.show_sidebar;
|
||||
return Ok((false, format!("Sidebar {}",
|
||||
if app_state.ui.show_sidebar { "shown" } else { "hidden" }
|
||||
)));
|
||||
}
|
||||
"next_field" => {
|
||||
// Increment field navigation
|
||||
if form_state.fields.len() > 0 {
|
||||
form_state.current_field = (form_state.current_field + 1) % form_state.fields.len();
|
||||
}
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
"prev_field" => {
|
||||
// Decrement field navigation
|
||||
if form_state.fields.len() > 0 {
|
||||
form_state.current_field = if form_state.current_field == 0 {
|
||||
form_state.fields.len() - 1
|
||||
} else {
|
||||
form_state.current_field - 1
|
||||
};
|
||||
}
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
"enter_command_mode" => {
|
||||
self.command_mode = true;
|
||||
self.command_input.clear();
|
||||
self.command_message.clear();
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
if UiStateHandler::toggle_sidebar(
|
||||
&mut app_state.ui,
|
||||
config,
|
||||
key_code,
|
||||
modifiers,
|
||||
) {
|
||||
return Ok((false, format!("Sidebar {}",
|
||||
if app_state.ui.show_sidebar { "shown" } else { "hidden" }
|
||||
)));
|
||||
}
|
||||
|
||||
// If no general action matched, return to stay in general mode
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
|
||||
// The rest of the function handles other modes as before
|
||||
// Handle toggling sidebar which is common across modes
|
||||
if UiStateHandler::toggle_sidebar(
|
||||
&mut app_state.ui,
|
||||
config,
|
||||
key_code,
|
||||
modifiers,
|
||||
) {
|
||||
return Ok((false, format!("Sidebar {}",
|
||||
if app_state.ui.show_sidebar { "shown" } else { "hidden" }
|
||||
)));
|
||||
}
|
||||
|
||||
// Handle edit mode first to allow normal character input
|
||||
if self.is_edit_mode {
|
||||
|
||||
Reference in New Issue
Block a user