mirror of
https://github.com/msfjarvis/text-editor.git
synced 2024-06-03 04:18:57 +05:30
fix(editor): keep cursor hidden during refresh
Prevents a potentially annoying flicker
This commit is contained in:
parent
a792bd2d1f
commit
5bb39b0618
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
@ -50,4 +50,12 @@ impl Terminal {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hide_cursor() {
|
||||
print!("{}", termion::cursor::Hide);
|
||||
}
|
||||
|
||||
pub fn show_cursor() {
|
||||
print!("{}", termion::cursor::Show);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user