mirror of https://github.com/TaKO8Ki/gobang
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.
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
pub mod connection_list;
|
|
pub mod database_list;
|
|
pub mod query;
|
|
pub mod record_table;
|
|
pub mod structure_table;
|
|
|
|
use crate::app::{App, FocusBlock};
|
|
use crate::components::tab::Tab;
|
|
use crate::components::Component as _;
|
|
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 => database_list::handler(key, app).await?,
|
|
FocusBlock::Table => match app.tab.selected_tab {
|
|
Tab::Records => record_table::handler(key, app).await?,
|
|
Tab::Structure => structure_table::handler(key, app).await?,
|
|
},
|
|
FocusBlock::Query => query::handler(key, app).await?,
|
|
}
|
|
match key {
|
|
Key::Char('d') => match app.focus_block {
|
|
FocusBlock::Query => (),
|
|
_ => app.focus_block = FocusBlock::DabataseList,
|
|
},
|
|
Key::Char('r') => match app.focus_block {
|
|
FocusBlock::Query => (),
|
|
_ => app.focus_block = FocusBlock::Table,
|
|
},
|
|
Key::Char('e') => app.focus_block = FocusBlock::Query,
|
|
Key::Esc => app.error = None,
|
|
key => app.tab.event(key)?,
|
|
}
|
|
Ok(())
|
|
}
|