fixed buffer logic
This commit is contained in:
20
client/src/buffer/logic.rs
Normal file
20
client/src/buffer/logic.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
// src/buffer/logic.rs
|
||||
use crossterm::event::{KeyCode, KeyModifiers};
|
||||
use crate::config::binds::config::Config;
|
||||
use crate::state::app::state::UiState;
|
||||
|
||||
/// Toggle the buffer list visibility based on keybindings.
|
||||
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
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
pub mod state;
|
||||
pub mod functions;
|
||||
pub mod ui;
|
||||
pub mod logic;
|
||||
|
||||
pub use state::{AppView, BufferState};
|
||||
pub use functions::*;
|
||||
pub use ui::render_buffer_list;
|
||||
pub use logic::toggle_buffer_list;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// src/modes/handlers/event.rs
|
||||
use crate::config::binds::config::Config;
|
||||
use crate::config::binds::key_sequences::KeySequenceTracker;
|
||||
use crate::buffer::{AppView, BufferState, switch_buffer, functions};
|
||||
use crate::buffer::{AppView, BufferState, switch_buffer, functions, toggle_buffer_list};
|
||||
use crate::sidebar::toggle_sidebar;
|
||||
use crate::functions::modes::navigation::add_logic_nav;
|
||||
use crate::functions::modes::navigation::add_logic_nav::SaveLogicResultSender;
|
||||
@@ -38,7 +38,6 @@ use crate::tui::{
|
||||
{admin, intro},
|
||||
};
|
||||
use crate::ui::handlers::context::UiContext;
|
||||
use crate::ui::handlers::rat_state::UiStateHandler;
|
||||
use canvas::KeyEventOutcome;
|
||||
use anyhow::Result;
|
||||
use common::proto::komp_ac::search::search_response::Hit;
|
||||
@@ -452,7 +451,7 @@ impl EventHandler {
|
||||
);
|
||||
return Ok(EventOutcome::Ok(message));
|
||||
}
|
||||
if UiStateHandler::toggle_buffer_list(
|
||||
if toggle_buffer_list(
|
||||
&mut app_state.ui,
|
||||
config,
|
||||
key_code,
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
pub mod ui;
|
||||
pub mod render;
|
||||
pub mod rat_state;
|
||||
pub mod context;
|
||||
|
||||
pub use ui::run_ui;
|
||||
pub use rat_state::*;
|
||||
pub use context::*;
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// 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_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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user