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.
52 lines
2.2 KiB
Rust
52 lines
2.2 KiB
Rust
use crate::app::{App, FocusBlock};
|
|
use crate::event::Key;
|
|
use crate::utils::get_records;
|
|
|
|
pub async fn handler(key: Key, app: &mut App, focused: bool) -> anyhow::Result<()> {
|
|
if focused {
|
|
match key {
|
|
Key::Char('j') => {
|
|
if app.selected_database.selected().is_some() {
|
|
app.record_table.column_index = 0;
|
|
app.next_table();
|
|
if let Some(database) = app.selected_database() {
|
|
if let Some(table) = app.selected_table() {
|
|
let (headers, records) =
|
|
get_records(database, table, app.pool.as_ref().unwrap()).await?;
|
|
app.record_table.state.select(Some(0));
|
|
app.record_table.headers = headers;
|
|
app.record_table.rows = records;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Key::Char('k') => {
|
|
if app.selected_database.selected().is_some() {
|
|
app.record_table.column_index = 0;
|
|
app.previous_table();
|
|
if let Some(database) = app.selected_database() {
|
|
if let Some(table) = app.selected_table() {
|
|
let (headers, records) =
|
|
get_records(database, table, app.pool.as_ref().unwrap()).await?;
|
|
app.record_table.state.select(Some(0));
|
|
app.record_table.headers = headers;
|
|
app.record_table.rows = records;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Key::Esc => app.focus_block = FocusBlock::TableList(false),
|
|
_ => (),
|
|
}
|
|
} else {
|
|
match key {
|
|
Key::Char('k') => app.focus_block = FocusBlock::DabataseList(false),
|
|
Key::Char('l') => app.focus_block = FocusBlock::RecordTable(false),
|
|
Key::Char('c') => app.focus_block = FocusBlock::ConnectionList,
|
|
Key::Enter => app.focus_block = FocusBlock::TableList(true),
|
|
_ => (),
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|