You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gobang/src/handlers/mod.rs

39 lines
1.4 KiB
Rust

pub mod connection_list;
pub mod database_list;
pub mod query;
pub mod record_table;
pub mod table_list;
use crate::app::{App, FocusBlock};
use crate::event::Key;
pub async fn handle_app(key: Key, app: &mut App) -> anyhow::Result<()> {
match app.focus_block {
FocusBlock::ConnectionList => connection_list::handler(key, app).await?,
FocusBlock::DabataseList(focused) => database_list::handler(key, app, focused).await?,
FocusBlock::TableList(focused) => table_list::handler(key, app, focused).await?,
FocusBlock::RecordTable(focused) => record_table::handler(key, app, focused).await?,
FocusBlock::Query(focused) => query::handler(key, app, focused).await?,
}
match key {
Key::Char('d') => match app.focus_block {
FocusBlock::Query(true) => (),
_ => app.focus_block = FocusBlock::DabataseList(true),
},
Key::Char('t') => match app.focus_block {
FocusBlock::Query(true) => (),
_ => app.focus_block = FocusBlock::TableList(true),
},
Key::Char('r') => match app.focus_block {
FocusBlock::Query(true) => (),
_ => app.focus_block = FocusBlock::RecordTable(true),
},
Key::Char('e') => app.focus_block = FocusBlock::Query(true),
Key::Right => app.next_tab(),
Key::Left => app.previous_tab(),
Key::Esc => app.error = None,
_ => (),
}
Ok(())
}