mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04:00
render: scrollback indicator: render relative indicator "smoothly"
That is, don't require it to be placed on a grid row.
This commit is contained in:
parent
ee5c9d714a
commit
9bc10cdb01
1 changed files with 7 additions and 7 deletions
14
render.c
14
render.c
|
|
@ -1353,10 +1353,10 @@ render_scrollback_position(struct terminal *term)
|
||||||
* 0% -> at the beginning of the scrollback
|
* 0% -> at the beginning of the scrollback
|
||||||
* 100% -> at the bottom, i.e. where new lines are inserted
|
* 100% -> at the bottom, i.e. where new lines are inserted
|
||||||
*/
|
*/
|
||||||
unsigned percent =
|
double percent =
|
||||||
rebased_view + term->rows == term->grid->num_rows
|
rebased_view + term->rows == term->grid->num_rows
|
||||||
? 100
|
? 1.0
|
||||||
: 100 * rebased_view / term->grid->num_rows;
|
: (double)rebased_view / term->grid->num_rows;
|
||||||
|
|
||||||
wchar_t text[64];
|
wchar_t text[64];
|
||||||
int cell_count;
|
int cell_count;
|
||||||
|
|
@ -1364,7 +1364,7 @@ render_scrollback_position(struct terminal *term)
|
||||||
/* *What* to render */
|
/* *What* to render */
|
||||||
switch (term->conf->scrollback.indicator.format) {
|
switch (term->conf->scrollback.indicator.format) {
|
||||||
case SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE:
|
case SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE:
|
||||||
swprintf(text, sizeof(text) / sizeof(text[0]), L"%u%%", percent);
|
swprintf(text, sizeof(text) / sizeof(text[0]), L"%u%%", (int)(100 * percent));
|
||||||
cell_count = 3;
|
cell_count = 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -1424,11 +1424,11 @@ render_scrollback_position(struct terminal *term)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCROLLBACK_INDICATOR_STYLE_RELATIVE: {
|
case SCROLLBACK_INDICATOR_STYLE_RELATIVE: {
|
||||||
int lines = term->rows - 2; /* Avoid using first and last row */
|
int lines = term->rows - 3; /* Avoid using first and two last rows */
|
||||||
assert(lines > 0);
|
assert(lines > 0);
|
||||||
|
|
||||||
int on_line = 1 + percent * lines / 100;
|
int pixels = lines * term->cell_height - height + 2 * margin;
|
||||||
surf_top = on_line * term->cell_height - margin;
|
surf_top = term->cell_height - margin + (int)(percent * pixels);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue