mirror of
https://github.com/helix-editor/helix.git
synced 2025-04-02 02:17:44 +03:00
crossterm: Render with synchronized output
This takes advantage of the synchronized output commands from crossterm to tell the terminal emulator when to pause and resume drawing. This should feel snappier and have fewer visual artifacts like tearing when we update the screen with many changes (scrolling or changing theme for example).
This commit is contained in:
parent
9558cb4002
commit
2234d94b50
1 changed files with 15 additions and 1 deletions
|
@ -146,6 +146,10 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn supports_synchronized_output(&self) -> bool {
|
||||
self.features().synchronized_output_mode != SynchronizedOutputMode::NotSupported
|
||||
}
|
||||
}
|
||||
|
||||
impl<W> Write for CrosstermBackend<W>
|
||||
|
@ -268,6 +272,10 @@ where
|
|||
where
|
||||
I: Iterator<Item = (u16, u16, &'a Cell)>,
|
||||
{
|
||||
if self.supports_synchronized_output() {
|
||||
queue!(self.buffer, terminal::BeginSynchronizedUpdate)?;
|
||||
}
|
||||
|
||||
let mut fg = Color::Reset;
|
||||
let mut bg = Color::Reset;
|
||||
let mut underline_color = Color::Reset;
|
||||
|
@ -326,7 +334,13 @@ where
|
|||
SetForegroundColor(CColor::Reset),
|
||||
SetBackgroundColor(CColor::Reset),
|
||||
SetAttribute(CAttribute::Reset)
|
||||
)
|
||||
)?;
|
||||
|
||||
if self.supports_synchronized_output() {
|
||||
execute!(self.buffer, terminal::EndSynchronizedUpdate)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn hide_cursor(&mut self) -> io::Result<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue