vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: 23f2ec265786458a85285e0305e5d9ab8c5da993
Parent: 45b191c7557c2a3ef482237523d14450b40dd706
Author: Randy Palamar
Date:   Sun, 17 Nov 2024 08:30:22 -0700

fix off by one scroll region setting

Diffstat:
Mterminal.c | 21++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/terminal.c b/terminal.c @@ -775,18 +775,17 @@ set_colours(Term *t, CSI *csi) } static void -set_scrolling_region(Term *t, CSI *csi) +set_scrolling_region(Term *t, i32 top, i32 bot) { - t->top = csi->argv[0]? csi->argv[0] : 0; - t->bot = csi->argv[1]? csi->argv[1] : t->size.h - 1; - CLAMP(t->top, 0, t->size.h - 1); - CLAMP(t->bot, 0, t->size.h - 1); - if (t->top > t->bot) { - i32 tmp = t->top; - t->top = t->bot; - t->bot = tmp; + CLAMP(top, 0, t->size.h - 1); + CLAMP(bot, 0, t->size.h - 1); + if (top > bot) { + i32 tmp = top; + top = bot; + bot = tmp; } - cursor_move_to(t, 0, 0); + t->top = top; + t->bot = bot; } static void @@ -899,7 +898,7 @@ handle_csi(Term *t, CSI *csi) case 'r': if (csi->priv) goto unknown; - set_scrolling_region(t, csi); + set_scrolling_region(t, ORONE(csi->argv[0]) - 1, ORONE(csi->argv[1]) - 1); cursor_move_abs_to(t, 0, 0); break; case 't': window_manipulation(t, csi); break;