mod alt_scroll;
mod clipboard;
mod copy_reply;
mod ctrl_c;
mod keybinds;
mod keyboard;
mod mode_keys;
mod mouse;
mod okr;
mod okr_save;
mod overlay_scroll;
mod paste;
mod scroll_down;
mod scroll_up;
mod tests;
use std::path::Path;
use std::sync::Arc;
use crossterm::event::{KeyEvent, KeyEventKind};
use tokio::sync::mpsc;
use crate::provider::ProviderRegistry;
use crate::session::{Session, SessionEvent};
use crate::tui::app::state::App;
use crate::tui::worker_bridge::TuiWorkerBridge;
use keybinds::handle_unmodified_key;
use keyboard::handle_ctrl_key;
pub use mouse::handle_mouse_event;
pub use paste::handle_paste_event;
pub async fn handle_event(
app: &mut App,
cwd: &Path,
session: &mut Session,
registry: &Option<Arc<ProviderRegistry>>,
worker_bridge: &Option<TuiWorkerBridge>,
event_tx: &mpsc::Sender<SessionEvent>,
result_tx: &mpsc::Sender<anyhow::Result<Session>>,
key: KeyEvent,
) -> anyhow::Result<bool> {
if key.kind != KeyEventKind::Press {
return Ok(false);
}
if let Some(result) = handle_ctrl_key(app, cwd, key) {
return result;
}
let out = handle_unmodified_key(
app,
cwd,
session,
registry,
worker_bridge,
event_tx,
result_tx,
key,
)
.await;
app.state.last_key_at = Some(std::time::Instant::now());
out
}