vtgl

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

Commit: fa3d50abb359c1e0f477e700ed2cce57f475fbb0
Parent: 4d3b84d51afc507ef8ed27180caede7a47d3d5be
Author: Randy Palamar
Date:   Fri, 23 Aug 2024 06:51:43 -0600

fix line splitting for certain cursor movements

Diffstat:
Mterminal.c | 31+++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/terminal.c b/terminal.c @@ -204,6 +204,15 @@ cursor_step_column(Term *t, i32 step) fb_scroll_up(t, 0, 1); } +/* NOTE: steps the cursor without causing a scroll */ +static void +cursor_step_raw(Term *t, i32 step, i32 rows, i32 cols) +{ + rows *= step; + cols *= step; + cursor_move_to(t, t->cursor.pos.y + rows, t->cursor.pos.x + cols); +} + static void term_reset(Term *t) { @@ -560,19 +569,19 @@ handle_csi(Term *t, s8 *raw) u8 next; switch (csi.mode) { - case 'A': cursor_move_to(t, p.y - ORONE(csi.argv[0]), p.x); break; - case 'B': cursor_move_to(t, p.y + ORONE(csi.argv[0]), p.x); break; - case 'C': cursor_move_to(t, p.y, p.x + ORONE(csi.argv[0])); break; - case 'D': cursor_move_to(t, p.y, p.x - ORONE(csi.argv[0])); break; + case 'A': cursor_step_raw(t, ORONE(csi.argv[0]), -1, 0); break; + case 'B': cursor_step_raw(t, ORONE(csi.argv[0]), 1, 0); break; + case 'C': cursor_step_raw(t, ORONE(csi.argv[0]), 0, 1); break; + case 'D': cursor_step_raw(t, ORONE(csi.argv[0]), 0, -1); break; case 'E': cursor_move_to(t, p.y + ORONE(csi.argv[0]), 0); break; case 'F': cursor_move_to(t, p.y - ORONE(csi.argv[0]), 0); break; case 'G': cursor_move_to(t, p.y, csi.argv[0] - 1); break; case 'H': cursor_move_to(t, csi.argv[0] - 1, csi.argv[1] - 1); break; case 'J': erase_in_display(t, &csi); break; case 'K': erase_in_line(t, &csi); break; - case 'a': cursor_move_to(t, p.y, p.x + ORONE(csi.argv[0])); break; + case 'a': cursor_step_raw(t, ORONE(csi.argv[0]), 0, 1); break; case 'd': cursor_move_to(t, csi.argv[0] - 1, p.x); break; - case 'e': cursor_move_to(t, p.y + ORONE(csi.argv[0]), p.x); break; + case 'e': cursor_step_raw(t, ORONE(csi.argv[0]), 1, 0); break; case 'h': set_mode(t, &csi, 1); break; case 'l': set_mode(t, &csi, 0); break; case 'm': set_colours(t, &csi); break; @@ -736,7 +745,17 @@ check_if_csi_moves_cursor(Term *t, s8 *raw) u32 term_mode = t->mode; switch (csi.mode) { + case 'A': result = EMC_CURSOR_MOVED; break; + case 'B': result = EMC_CURSOR_MOVED; break; + case 'C': result = EMC_CURSOR_MOVED; break; + case 'D': result = EMC_CURSOR_MOVED; break; + case 'E': result = EMC_CURSOR_MOVED; break; + case 'F': result = EMC_CURSOR_MOVED; break; + case 'G': result = EMC_CURSOR_MOVED; break; case 'H': result = EMC_CURSOR_MOVED; break; + case 'a': result = EMC_CURSOR_MOVED; break; + case 'd': result = EMC_CURSOR_MOVED; break; + case 'e': result = EMC_CURSOR_MOVED; break; case 'h': set_mode(t, &csi, 1); break; case 'l': set_mode(t, &csi, 0); break; case 'm': set_colours(t, &csi); break;