some updates to the loop
This commit is contained in:
1 parent
6392460cb0
commit
85f1ce125b
1 file changed
+14
-16
+14
-16
@@ -129,13 +129,23 @@ impl TerminalUI {
|
||||
|
||||
async fn run(&mut self) -> Result<()> {
|
||||
info!("Starting to run tui");
|
||||
let (update_tx, mut update_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
|
||||
|
||||
'outer: loop {
|
||||
let evt = self.event_handler.next().await.unwrap();
|
||||
match evt {
|
||||
Event::Render => {
|
||||
update_tx.send(())?;
|
||||
// Process any pending commands
|
||||
self.editor_core.process_commands();
|
||||
|
||||
// Render the current state
|
||||
self.terminal.draw(|mut frame| {
|
||||
self.terminal_state
|
||||
.render(&mut frame, &mut self.editor_core)
|
||||
})?;
|
||||
|
||||
if self.editor_core.should_quit {
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
Event::Key(key) => {
|
||||
let action = match key.code {
|
||||
@@ -149,20 +159,8 @@ impl TerminalUI {
|
||||
self.editor_core.send_input(action);
|
||||
}
|
||||
}
|
||||
|
||||
self.editor_core.process_commands();
|
||||
|
||||
while let Ok(()) = update_rx.try_recv() {
|
||||
self.terminal.draw(|mut frame| {
|
||||
self.terminal_state
|
||||
.render(&mut frame, &mut self.editor_core)
|
||||
})?;
|
||||
if self.editor_core.should_quit {
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user