add a event for movining focus and table component

pull/84/head
Takayuki Maeda 3 years ago
parent a3cf9b570f
commit a4d881f3f6

@ -7,13 +7,10 @@ use crate::database::{ExecuteResult, Pool};
use crate::event::Key; use crate::event::Key;
use anyhow::Result; use anyhow::Result;
use async_trait::async_trait; use async_trait::async_trait;
use database_tree::Table;
use sqlx::query::Query;
use tui::{ use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
style::{Color, Style}, style::{Color, Style},
text::Text,
widgets::{Block, Borders, Paragraph, Wrap}, widgets::{Block, Borders, Paragraph, Wrap},
Frame, Frame,
}; };
@ -84,16 +81,19 @@ impl Component for SqlEditorComponent {
fn commands(&self, _out: &mut Vec<CommandInfo>) {} fn commands(&self, _out: &mut Vec<CommandInfo>) {}
fn event(&mut self, key: Key) -> Result<EventState> { fn event(&mut self, key: Key) -> Result<EventState> {
if key == self.key_config.focus_above && matches!(self.focus, Focus::Table) {
self.focus = Focus::Editor
}
match key { match key {
Key::Char(c) => { Key::Char(c) if matches!(self.focus, Focus::Editor) => {
self.input.push(c); self.input.push(c);
return Ok(EventState::Consumed); return Ok(EventState::Consumed);
} }
key if matches!(self.focus, Focus::Table) => return self.table.event(key),
_ => (), _ => (),
} }
return Ok(EventState::NotConsumed);
Ok(EventState::NotConsumed)
} }
async fn async_event(&mut self, key: Key, pool: &Box<dyn Pool>) -> Result<EventState> { async fn async_event(&mut self, key: Key, pool: &Box<dyn Pool>) -> Result<EventState> {

Loading…
Cancel
Save