Allow forcing an area to be redrawn
Problem
At the moment, the diff algorithm is always applied on any area. There are however situation where it would make sense to force an area to be drawn again.
I'm facing this problem while working in the minitel backend, as this terminal has the particularity of defining background color with a "zone" defined by row with spaces containing the background attributes.
To draw a row of yellow background [YYYYYY], you would send to the terminal [<Y>␣␣␣␣␣␣].
Now, if a pop-up is drawn in the middle with a white background: [YYWWYY], the diff will only be [␣␣WW␣␣] leading [␣␣<W>␣␣␣␣] to be sent to the device, instead of [␣␣<W>␣␣<Y>␣␣].
After drawing the new white background, you end up with [YYWWWW] because the backend does not know about the additional yellow background to send again.
Solution
A suggested solution is to expose an ability similar to skip cell, but forcing the cell to be redrawn. This may be exposed through a ForceRedraw widget similar to Clear.
The application developer still need to know about its terminal limitation, and take it in account, with snippets similar to:
let popup_area = ...;
let force_redraw_area = Rect::new(
popup_area.right(),
popup_area.top(),
1,
popup_area.height,
);
ForceRedraw::default().render(force_redraw_area, buf);
Alternatives
- Using the
Clearwidget: This cannot be done in a single frame, even when usingClearand then redefining the yellow background, the yellow will be removed by the diff - Managing all in the backend, keeping its own buffer of "areas": Certainly doable.
Additional context
Another situation where it could be useful is when the terminal may be modified from an external source.
Source: ratatui/ratatui