39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
// client/src/ui/handlers/rat_state.rs
|
|
use crossterm::event::{KeyCode, KeyModifiers};
|
|
use crate::config::binds::config::Config;
|
|
use crate::state::app::state::UiState;
|
|
|
|
pub struct UiStateHandler;
|
|
|
|
impl UiStateHandler {
|
|
pub fn toggle_sidebar(
|
|
ui_state: &mut UiState,
|
|
config: &Config,
|
|
key: KeyCode,
|
|
modifiers: KeyModifiers,
|
|
) -> bool {
|
|
if let Some(action) = config.get_action_for_key_in_mode(&config.keybindings.common, key, modifiers) {
|
|
if action == "toggle_sidebar" {
|
|
ui_state.show_sidebar = !ui_state.show_sidebar;
|
|
return true;
|
|
}
|
|
}
|
|
false
|
|
}
|
|
|
|
pub fn toggle_buffer_list(
|
|
ui_state: &mut UiState,
|
|
config: &Config,
|
|
key: KeyCode,
|
|
modifiers: KeyModifiers,
|
|
) -> bool {
|
|
if let Some(action) = config.get_common_action(key, modifiers) {
|
|
if action == "toggle_buffer_list" {
|
|
ui_state.show_buffer_list = !ui_state.show_buffer_list;
|
|
return true;
|
|
}
|
|
}
|
|
false
|
|
}
|
|
}
|