Skip to content

Commit f3f6b92

Browse files
author
Stephan Dilly
committed
draw once before mainloop to appear more snappy
1 parent 317fd6a commit f3f6b92

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ use std::{
3333
io, panic,
3434
time::{Duration, Instant},
3535
};
36-
use tui::{backend::CrosstermBackend, Terminal};
36+
use tui::{
37+
backend::{Backend, CrosstermBackend},
38+
Terminal,
39+
};
3740

3841
static TICK_INTERVAL: Duration = Duration::from_secs(5);
3942

@@ -65,6 +68,7 @@ fn main() -> Result<()> {
6568
let ticker = tick(TICK_INTERVAL);
6669

6770
app.update();
71+
draw(&mut terminal, &mut app)?;
6872

6973
loop {
7074
let events: Vec<QueueEvent> =
@@ -81,7 +85,7 @@ fn main() -> Result<()> {
8185
}
8286
}
8387

84-
terminal.draw(|mut f| app.draw(&mut f))?;
88+
draw(&mut terminal, &mut app)?;
8589

8690
if app.is_quit() {
8791
break;
@@ -92,6 +96,13 @@ fn main() -> Result<()> {
9296
Ok(())
9397
}
9498

99+
fn draw<B: Backend>(
100+
terminal: &mut Terminal<B>,
101+
app: &mut App,
102+
) -> io::Result<()> {
103+
terminal.draw(|mut f| app.draw(&mut f))
104+
}
105+
95106
fn invalid_path() -> bool {
96107
!asyncgit::is_repo(asyncgit::CWD)
97108
}

0 commit comments

Comments
 (0)