From 290bc5567e0dee388e2eaa694d4206dc5c8daede Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 6 Apr 2020 07:52:56 -0700 Subject: [PATCH] termwiz: windows: tidy up flushing a bit --- termwiz/src/render/windows.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/termwiz/src/render/windows.rs b/termwiz/src/render/windows.rs index 8c6763bf8..583d49d62 100644 --- a/termwiz/src/render/windows.rs +++ b/termwiz/src/render/windows.rs @@ -223,19 +223,23 @@ impl ScreenBuffer { Ok(()) } + fn flush(&mut self, out: &mut B) -> anyhow::Result<()> { + self.flush_screen(out)?; + let info = out.get_buffer_info()?; + out.set_cursor_position( + self.cursor_x as i16, + self.cursor_y as i16 + info.srWindow.Top, + )?; + out.set_attr(self.pending_attr)?; + out.flush()?; + Ok(()) + } + fn flush_screen(&mut self, out: &mut B) -> anyhow::Result<()> { if self.dirty { out.flush()?; out.set_buffer_contents(&self.buf)?; out.flush()?; - let info = out.get_buffer_info()?; - out.set_cursor_position( - self.cursor_x.min(self.cols - 1) as i16, - (self.cursor_y as i16 + info.srWindow.Top).min(self.rows as i16 - 1), - )?; - out.flush()?; - out.set_attr(self.pending_attr)?; - out.flush()?; self.dirty = false; } Ok(()) @@ -457,7 +461,7 @@ impl WindowsConsoleRenderer { } } - buffer.flush_screen(out)?; + buffer.flush(out)?; Ok(()) } }