diff --git a/Cargo.toml b/Cargo.toml index 59af05f..de814df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,7 @@ bitflags = "2.5.0" regex = "1.10.4" indexmap = "2.2.6" tui-prompts = "0.3.11" +# tui-prompts = { version = "0.3.11", path = "../../contrib/tui-prompts" } # tui-popup = { version = "0.3.0", path = "../../contrib/tui-popup" } [dev-dependencies] diff --git a/src/tui/app.rs b/src/tui/app.rs index 11f1891..6c8b743 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -359,7 +359,17 @@ impl App { return Ok(()); } Action::Render => { - tui.draw(|f| self.render(f.size(), f.buffer_mut()))?; + tui.draw(|f| { + self.render(f.size(), f.buffer_mut()); + self + .query_builder + .as_ref() + .filter(|q| q.editing()) + .inspect(|q| { + let (x, y) = q.cursor(); + f.set_cursor(x, y); + }); + })?; } Action::NextItem => { self.event_list.next(); @@ -475,9 +485,13 @@ impl App { } Action::BeginSearch => { if let Some(query_builder) = self.query_builder.as_mut() { + // action_tx.send(query_builder.edit())?; query_builder.edit(); } else { - self.query_builder = Some(QueryBuilder::new(QueryKind::Search)); + let mut query_builder = QueryBuilder::new(QueryKind::Search); + // action_tx.send(query_builder.edit())?; + query_builder.edit(); + self.query_builder = Some(query_builder); } } Action::EndSearch => { diff --git a/src/tui/query.rs b/src/tui/query.rs index 18d2b13..58e35d1 100644 --- a/src/tui/query.rs +++ b/src/tui/query.rs @@ -137,6 +137,13 @@ impl QueryBuilder { pub fn edit(&mut self) { self.editing = true; + self.state.focus(); + } + + /// Get the current cursor position, + /// this should be called after render is called + pub fn cursor(&self) -> (u16, u16) { + self.state.cursor() } pub fn handle_key_events(&mut self, key: KeyEvent) -> Result, String> {