| 689 |
689 |
|
}
|
| 690 |
690 |
|
}
|
| 691 |
691 |
|
|
|
692 |
+ |
/// Report every row as damaged, for a renderer that lost its own cache.
|
|
693 |
+ |
///
|
|
694 |
+ |
/// Damage is a diff, and a diff only works while both ends agree on what
|
|
695 |
+ |
/// the other has. The renderer keeps a per-row glyph cache and rebuilds
|
|
696 |
+ |
/// only the rows damage names, so anything that throws that cache away —
|
|
697 |
+ |
/// rebuilding the renderer on a scale change is the live case — leaves the
|
|
698 |
+ |
/// two ends disagreeing: the grid has nothing new to report, the renderer
|
|
699 |
+ |
/// has nothing at all, and the window stays empty until the program on the
|
|
700 |
+ |
/// pty happens to print. A shell prints on the next keystroke and hides
|
|
701 |
+ |
/// this; a command that writes once and waits does not.
|
|
702 |
+ |
///
|
|
703 |
+ |
/// So this is not a redraw request but the renderer saying it forgot, and
|
|
704 |
+ |
/// the grid answering with the whole screen.
|
|
705 |
+ |
pub fn invalidate_render(&mut self) {
|
|
706 |
+ |
self.mark_all_rows_dirty();
|
|
707 |
+ |
self.view_dirty = true;
|
|
708 |
+ |
}
|
|
709 |
+ |
|
| 692 |
710 |
|
pub fn cursor_shape(&self) -> CursorShape {
|
| 693 |
711 |
|
self.cursor_shape
|
| 694 |
712 |
|
}
|
| 3533 |
3551 |
|
let b = a;
|
| 3534 |
3552 |
|
assert_eq!(a, b);
|
| 3535 |
3553 |
|
}
|
|
3554 |
+ |
|
|
3555 |
+ |
#[test]
|
|
3556 |
+ |
fn invalidate_render_reports_every_row_however_quiet_the_grid_is() {
|
|
3557 |
+ |
// The renderer rebuilt itself and lost its cache. Nothing about the
|
|
3558 |
+ |
// grid changed, which is exactly why it cannot be left to report the
|
|
3559 |
+ |
// difference: there isn't one, and the window would stay empty until
|
|
3560 |
+ |
// the program on the pty happened to print.
|
|
3561 |
+ |
let mut g = Grid::new(8, 4);
|
|
3562 |
+ |
feed(&mut g, b"one\r\ntwo");
|
|
3563 |
+ |
let _ = g.take_damage();
|
|
3564 |
+ |
assert!(
|
|
3565 |
+ |
g.take_damage().dirty_rows.is_empty(),
|
|
3566 |
+ |
"a quiet grid still had damage to report"
|
|
3567 |
+ |
);
|
|
3568 |
+ |
g.invalidate_render();
|
|
3569 |
+ |
let d = g.take_damage();
|
|
3570 |
+ |
assert_eq!(d.dirty_rows.len(), 4, "not every row came back");
|
|
3571 |
+ |
assert!(d.view_moved, "the viewport was not invalidated with them");
|
|
3572 |
+ |
}
|
| 3536 |
3573 |
|
}
|