mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
term: scrolling: calling function must clamp scroll amount
This commit is contained in:
parent
dea36de7e3
commit
550667a9ea
2 changed files with 16 additions and 8 deletions
16
csi.c
16
csi.c
|
|
@ -650,13 +650,21 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
|||
break;
|
||||
}
|
||||
|
||||
case 'S':
|
||||
term_scroll(term, vt_param_get(term, 0, 1));
|
||||
case 'S': {
|
||||
int amount = min(
|
||||
vt_param_get(term, 0, 1),
|
||||
term->scroll_region.end - term->scroll_region.start);
|
||||
term_scroll(term, amount);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'T':
|
||||
term_scroll_reverse(term, vt_param_get(term, 0, 1));
|
||||
case 'T': {
|
||||
int amount = min(
|
||||
vt_param_get(term, 0, 1),
|
||||
term->scroll_region.end - term->scroll_region.start);
|
||||
term_scroll_reverse(term, amount);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'X': {
|
||||
/* Erase chars */
|
||||
|
|
|
|||
|
|
@ -1744,8 +1744,8 @@ term_scroll_partial(struct terminal *term, struct scroll_region region, int rows
|
|||
LOG_DBG("scroll: rows=%d, region.start=%d, region.end=%d",
|
||||
rows, region.start, region.end);
|
||||
|
||||
/* Clamp scroll amount */
|
||||
rows = min(rows, region.end - region.start);
|
||||
/* Verify scroll amount has been clamped */
|
||||
assert(rows <= region.end - region.start);
|
||||
|
||||
/* Cancel selections that cannot be scrolled */
|
||||
if (unlikely(term->selection.start.row != -1)) {
|
||||
|
|
@ -1816,8 +1816,8 @@ term_scroll_reverse_partial(struct terminal *term,
|
|||
LOG_DBG("scroll reverse: rows=%d, region.start=%d, region.end=%d",
|
||||
rows, region.start, region.end);
|
||||
|
||||
/* Clamp scroll amount */
|
||||
rows = min(rows, region.end - region.start);
|
||||
/* Verify scroll amount has been clamped */
|
||||
assert(rows <= region.end - region.start);
|
||||
|
||||
/* Cancel selections that cannot be scrolled */
|
||||
if (unlikely(term->selection.start.row != -1)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue