Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpasmantier committed Sep 18, 2024
1 parent 52c48bb commit a45a4f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
17 changes: 17 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -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
-
9 changes: 3 additions & 6 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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:?}");
Expand All @@ -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)?,
_ => {}
Expand Down

0 comments on commit a45a4f7

Please sign in to comment.