feat(backend): keep the internal buffers in sync when the terminal is cleared.

pull/376/head
Florian Dehau 4 years ago
parent ecb482f297
commit 90f3858eff

@ -229,10 +229,9 @@ where
/// This leads to a full clear of the screen. /// This leads to a full clear of the screen.
pub fn resize(&mut self, area: Rect) -> io::Result<()> { pub fn resize(&mut self, area: Rect) -> io::Result<()> {
self.buffers[self.current].resize(area); self.buffers[self.current].resize(area);
self.buffers[1 - self.current].reset();
self.buffers[1 - self.current].resize(area); self.buffers[1 - self.current].resize(area);
self.viewport.area = area; self.viewport.area = area;
self.backend.clear() self.clear()
} }
/// Queries the backend for size and resizes if it doesn't match the previous size. /// Queries the backend for size and resizes if it doesn't match the previous size.
@ -303,8 +302,12 @@ where
self.backend.set_cursor(x, y) self.backend.set_cursor(x, y)
} }
/// Clear the terminal and force a full redraw on the next draw call.
pub fn clear(&mut self) -> io::Result<()> { pub fn clear(&mut self) -> io::Result<()> {
self.backend.clear() self.backend.clear()?;
// Reset the back buffer to make sure the next update will redraw everything.
self.buffers[1 - self.current].reset();
Ok(())
} }
/// Queries the real size of the backend. /// Queries the real size of the backend.

Loading…
Cancel
Save