use crossterm::event::KeyEvent;
use super::super::utils::matches_any;
use super::normal_mode::{handle_export, handle_menu_toggles};
use crate::state::AppState;
pub fn handle_shift_keybinds(ke: &KeyEvent, app: &mut AppState) -> bool {
if handle_menu_toggles(ke, app) {
return true;
}
if matches_any(ke, &app.keymap.search_normal_import) {
if !app.installed_only_mode {
app.modal = crate::state::Modal::ImportHelp;
}
return true;
}
if matches_any(ke, &app.keymap.search_normal_export) {
handle_export(app);
return true;
}
if matches_any(ke, &app.keymap.search_normal_updates) {
if matches!(app.app_mode, crate::state::types::AppMode::News) {
crate::events::mouse::handle_news_button(app);
} else {
crate::events::mouse::handle_updates_button(app);
}
return true;
}
if matches_any(ke, &app.keymap.search_normal_open_status) {
crate::util::open_url("https://status.archlinux.org");
return true;
}
false
}
pub fn navigate_pane(
app: &mut AppState,
direction: &str,
details_tx: &tokio::sync::mpsc::UnboundedSender<crate::state::PackageItem>,
preview_tx: &tokio::sync::mpsc::UnboundedSender<crate::state::PackageItem>,
) {
if matches!(app.app_mode, crate::state::types::AppMode::News) {
match direction {
"right" => {
app.focus = crate::state::Focus::Install; }
"left" => {
app.focus = crate::state::Focus::Recent; }
_ => {}
}
return;
}
match direction {
"right" => {
if app.installed_only_mode {
app.right_pane_focus = crate::state::RightPaneFocus::Downgrade;
if app.downgrade_state.selected().is_none() && !app.downgrade_list.is_empty() {
app.downgrade_state.select(Some(0));
}
app.focus = crate::state::Focus::Install;
super::super::utils::refresh_downgrade_details(app, details_tx);
} else {
if app.install_state.selected().is_none() && !app.install_list.is_empty() {
app.install_state.select(Some(0));
}
app.focus = crate::state::Focus::Install;
super::super::utils::refresh_install_details(app, details_tx);
}
}
"left" => {
if app.history_state.selected().is_none() && !app.recent.is_empty() {
app.history_state.select(Some(0));
}
app.focus = crate::state::Focus::Recent;
crate::ui::helpers::trigger_recent_preview(app, preview_tx);
}
_ => {}
}
}