Open vi opened 2 years ago
Hi - indeed, right now we re-draw the screen on any change or event.
ncurses includes some internal caching to only re-draw the changes, which the other backends don't do at the moment. However, there exists a third-party backend wrapper that brings this feature: https://github.com/agavrilov/cursive_buffered_backend
Eventually I plan on bringing this in cursive itself, but for now this wrapper may help your performance issue.
Tried cursive_buffered_backend
- flickering disappeared and bytes written to tty dropped from 174kb to 15kb. Both with crossterm
and termion
underlying backends. Also works with curses::n
backend, but with no visible change.
@gyscos Would a PR to integrate this into the Termion Backend
help?
The buffered backend would benefit both the termion and crossterm backends, and really could be integrated around the Printer
level.
The Printer
itself may benefit from a bit of re-structuring too (as discussed a bit in #652), so I might include some buffering like that when I get there.
Describe the bug
With default
ncurses
backend,cursive
applications feel smooth and does not blink in e.g. Alacritty. But with other backends (crossterm and termion), it seems like it just redraws the entire screen each time something is updated.Also in scenario where
ncurses
backend write only 11 KB to the tty, but with the pure-Rust backends I see 174 KB of data. This may become problematic if TUI applications are accessed over SSH with bad network.To Reproduce
Example application
``` extern crate cursive_table_view; use std::cmp::Ordering; use cursive::{ align::HAlign, traits::{Nameable, Resizable}, views::{TextView, LinearLayout, TextArea}, Cursive, With, }; use cursive_table_view::{TableView, TableViewItem}; #[derive(Copy, Clone, PartialEq, Eq, Hash)] enum MyColumn { Name, Count, Rate, } #[derive(Clone, Debug)] struct Foo { name: String, count: usize, rate: usize, } impl TableViewItemExpected behavior
Applications differ only by their filesize and dynamic dependencies, maybe some tricky feature support.
Environment
Other notes
If this cannot be fixed easily, then it should be documented in "Backends" wiki article. This blinking and tty bandwidth usage may be overseen by deploying developer, who might think that by switching to crossterm/termion one just gains easy deployment without any apparent loss in functionality.