fix: add missing flush

This commit is contained in:
🪞👃🪞 2024-09-15 17:36:20 +03:00
parent 530cba2bc8
commit 56db9cfce1
2 changed files with 3 additions and 2 deletions

View file

@ -106,7 +106,7 @@ impl Content for Demo<Tui> {
}
impl Handle<Tui> for Demo<Tui> {
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
match from.event() {
key!(KeyCode::PageUp) => {
self.index = (self.index + 1) % self.items.len();

View file

@ -61,7 +61,7 @@ impl Tui {
let engine = Arc::new(RwLock::new(engine));
let _input_thread = Self::spawn_input_thread(&engine, &state, Duration::from_millis(100));
engine.write().unwrap().setup()?;
let render_thread = Self::spawn_render_thread(&engine, &state, Duration::from_millis(20));
let render_thread = Self::spawn_render_thread(&engine, &state, Duration::from_millis(10));
render_thread.join().expect("main thread failed");
engine.write().unwrap().teardown()?;
Ok(state)
@ -122,6 +122,7 @@ impl Tui {
fn flip (&mut self, mut buffer: Buffer) -> Buffer {
let updates = self.buffer.diff(&buffer);
self.backend.draw(updates.into_iter()).expect("failed to render");
self.backend.flush();
std::mem::swap(&mut self.buffer, &mut buffer);
buffer.reset();
buffer