fix(editor): keep cursor hidden during refresh

Prevents a potentially annoying flicker
This commit is contained in:
Harsh Shandilya 2022-08-07 18:19:18 +05:30
parent a792bd2d1f
commit 5bb39b0618
No known key found for this signature in database
GPG Key ID: 366D7BBAD1031E80
2 changed files with 10 additions and 0 deletions

View File

@ -41,6 +41,7 @@ impl Editor {
}
fn refresh_screen(&self) -> Result<(), io::Error> {
Terminal::hide_cursor();
Terminal::clear_screen();
Terminal::reposition_cursor(0, 0);
if self.should_quit {
@ -49,6 +50,7 @@ impl Editor {
self.draw_rows();
Terminal::reposition_cursor(0, 0);
}
Terminal::show_cursor();
Terminal::flush()
}

View File

@ -50,4 +50,12 @@ impl Terminal {
}
}
}
pub fn hide_cursor() {
print!("{}", termion::cursor::Hide);
}
pub fn show_cursor() {
print!("{}", termion::cursor::Show);
}
}