diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..5a8fc1d --- /dev/null +++ b/TODO.md @@ -0,0 +1,17 @@ +- separate event loop from tui +- translate events into actions inside the event handler loop +- have a dedicated rendering loop that can own the tui +- + + + + +## feature ideas +- environment variables +- aliases +- shell history +- grep (maybe also inside pdfs and other files (see rga)) +- fd +- git +- makefile commands +- diff --git a/src/app.rs b/src/app.rs index 450073f..c82000e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -101,7 +101,7 @@ impl App { let action_tx = self.action_tx.clone(); loop { self.handle_events(&mut tui).await?; - self.handle_actions(&mut tui)?; + self.handle_actions()?; if self.should_suspend { tui.suspend()?; action_tx.send(Action::Resume)?; @@ -164,7 +164,7 @@ impl App { Ok(()) } - fn handle_actions(&mut self, tui: &mut Tui) -> Result<()> { + fn handle_actions(&mut self) -> Result<()> { while let Ok(action) = self.action_rx.try_recv() { if action != Action::Tick && action != Action::Render { debug!("{action:?}"); @@ -176,10 +176,7 @@ impl App { Action::Quit => self.should_quit = true, Action::Suspend => self.should_suspend = true, Action::Resume => self.should_suspend = false, - Action::ClearScreen => tui.terminal.clear()?, - // This needs to send a particular RenderingMessage to the rendering task - // in order to do: - // >> tui.resize(Rect::new(0, 0, w, h))?; + Action::ClearScreen => self.render_tx.send(RenderingTask::ClearScreen)?, Action::Resize(w, h) => self.render_tx.send(RenderingTask::Resize(w, h))?, Action::Render => self.render_tx.send(RenderingTask::Render)?, _ => {}