forked from NotAShelf/beer
beer/grid: scroll to fit image when cursor is near bottom
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ic95b18caca0c575b7d7452c87f9f1f956a6a6964
This commit is contained in:
parent
08f788dfae
commit
3775e25cdf
1 changed files with 19 additions and 1 deletions
|
|
@ -782,7 +782,25 @@ impl Grid {
|
||||||
rows: usize,
|
rows: usize,
|
||||||
keep_cursor: bool,
|
keep_cursor: bool,
|
||||||
) {
|
) {
|
||||||
let (x0, y0) = (self.cursor.x, self.cursor.y);
|
let x0 = self.cursor.x;
|
||||||
|
// Scroll the screen to make vertical room for the image. Only scroll
|
||||||
|
// when the full screen is the active scroll region; a DECSTBM region
|
||||||
|
// or the alternate screen keeps the image clipped as before.
|
||||||
|
let y0 = if self.top == 0
|
||||||
|
&& self.bottom == self.rows - 1
|
||||||
|
&& self.alt_saved.is_none()
|
||||||
|
{
|
||||||
|
let y0_initial = self.cursor.y;
|
||||||
|
let scroll_n = (y0_initial + rows)
|
||||||
|
.saturating_sub(self.rows)
|
||||||
|
.min(y0_initial);
|
||||||
|
if scroll_n > 0 {
|
||||||
|
self.scroll_up(scroll_n);
|
||||||
|
}
|
||||||
|
y0_initial - scroll_n
|
||||||
|
} else {
|
||||||
|
self.cursor.y
|
||||||
|
};
|
||||||
for dy in 0..rows {
|
for dy in 0..rows {
|
||||||
let cy = y0 + dy;
|
let cy = y0 + dy;
|
||||||
if cy >= self.rows {
|
if cy >= self.rows {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue