mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-18 22:05:25 -05:00
render: scrollback position: only count _used_ scrollback lines
When calculating where in the scrollback history we are, we previously did this against the total number of scrollback lines. I.e. the `scrollback.lines` setting in `footrc`. Now, we count only the used/allocated scrollback lines. Note that the initial indicator position might still seem to start a bit high up, if the number of used scrollback lines is low. This is because we use the *top* of the screen for the current position. Thus, we'll never be at the bottom (except for the special case when we're *really* at the bottom).
This commit is contained in:
parent
a2257cb082
commit
cc24c5f2e0
2 changed files with 13 additions and 3 deletions
14
render.c
14
render.c
|
|
@ -1399,14 +1399,22 @@ render_scrollback_position(struct terminal *term)
|
|||
|
||||
/* Find absolute row number of the scrollback start */
|
||||
int scrollback_start = term->grid->offset + term->rows;
|
||||
while (term->grid->rows[scrollback_start & (term->grid->num_rows - 1)] == NULL)
|
||||
int empty_rows = 0;
|
||||
while (term->grid->rows[scrollback_start & (term->grid->num_rows - 1)] == NULL) {
|
||||
scrollback_start++;
|
||||
empty_rows++;
|
||||
}
|
||||
|
||||
/* Rebase viewport against scrollback start (so that 0 is at
|
||||
* the beginning of the scrollback) */
|
||||
int rebased_view = term->grid->view - scrollback_start + term->grid->num_rows;
|
||||
rebased_view &= term->grid->num_rows - 1;
|
||||
|
||||
/* How much of the scrollback is actually used? */
|
||||
int populated_rows = term->grid->num_rows - empty_rows;
|
||||
assert(populated_rows > 0);
|
||||
assert(populated_rows <= term->grid->num_rows);
|
||||
|
||||
/*
|
||||
* How far down in the scrollback we are.
|
||||
*
|
||||
|
|
@ -1414,9 +1422,9 @@ render_scrollback_position(struct terminal *term)
|
|||
* 100% -> at the bottom, i.e. where new lines are inserted
|
||||
*/
|
||||
double percent =
|
||||
rebased_view + term->rows == term->grid->num_rows
|
||||
rebased_view + term->rows == populated_rows
|
||||
? 1.0
|
||||
: (double)rebased_view / term->grid->num_rows;
|
||||
: (double)rebased_view / populated_rows;
|
||||
|
||||
wchar_t _text[64];
|
||||
const wchar_t *text = _text;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue