From a4d881f3f6c56902d39d02a03450a2dc25e9ae24 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Thu, 9 Sep 2021 12:26:27 +0900 Subject: [PATCH] add a event for movining focus and table component --- src/components/sql_editor.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/sql_editor.rs b/src/components/sql_editor.rs index 0b17408..f2f3932 100644 --- a/src/components/sql_editor.rs +++ b/src/components/sql_editor.rs @@ -7,13 +7,10 @@ use crate::database::{ExecuteResult, Pool}; use crate::event::Key; use anyhow::Result; use async_trait::async_trait; -use database_tree::Table; -use sqlx::query::Query; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, style::{Color, Style}, - text::Text, widgets::{Block, Borders, Paragraph, Wrap}, Frame, }; @@ -84,16 +81,19 @@ impl Component for SqlEditorComponent { fn commands(&self, _out: &mut Vec) {} fn event(&mut self, key: Key) -> Result { + if key == self.key_config.focus_above && matches!(self.focus, Focus::Table) { + self.focus = Focus::Editor + } match key { - Key::Char(c) => { + Key::Char(c) if matches!(self.focus, Focus::Editor) => { self.input.push(c); return Ok(EventState::Consumed); } + key if matches!(self.focus, Focus::Table) => return self.table.event(key), _ => (), } - - Ok(EventState::NotConsumed) + return Ok(EventState::NotConsumed); } async fn async_event(&mut self, key: Key, pool: &Box) -> Result {