Commit: d8af0c3314ee05138b7aaacdc2bc830637e02eda
Parent: 7691b8a01f9d841cd1c9ac0d66aa0aa37b385df4
Author: Randy Palamar
Date: Sun, 25 Aug 2024 15:40:36 -0600
csi IL, DL, DCH (line insert/delete, char delete)
Diffstat:
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/terminal.c b/terminal.c
@@ -189,6 +189,9 @@ fb_clear_region(Term *t, u32 r1, u32 r2, u32 c1, u32 c2)
static void
fb_scroll_down(Term *t, u32 top, u32 n)
{
+ if (!BETWEEN(top, t->top, t->bot))
+ return;
+
TermView *tv = t->views + t->view_idx;
CLAMP(n, 0, t->bot - top + 1);
fb_clear_region(t, t->bot - n + 1, t->bot, 0, t->size.w);
@@ -203,6 +206,9 @@ fb_scroll_down(Term *t, u32 top, u32 n)
static void
fb_scroll_up(Term *t, u32 top, u32 n)
{
+ if (!BETWEEN(top, t->top, t->bot))
+ return;
+
TermView *tv = t->views + t->view_idx;
CLAMP(n, 0, t->bot - top + 1);
fb_clear_region(t, top, top + n - 1, 0, t->size.w);
@@ -364,7 +370,22 @@ erase_in_line(Term *t, CSI *csi)
}
}
-/* ECH: Erase Characters */
+/* IL: Insert <count> blank lines */
+static void
+insert_blank_lines(Term *t, i32 count)
+{
+ fb_scroll_down(t, t->cursor.pos.y, count);
+}
+
+/* DL: Erase <count> lines */
+static void
+erase_lines(Term *t, i32 count)
+{
+ fb_scroll_up(t, t->cursor.pos.y, count);
+}
+
+/* DCH: Delete Characters (NOTE: DCH is technically different but we are ignoring that) */
+/* ECH: Erase Characters */
static void
erase_characters(Term *t, i32 count)
{
@@ -681,6 +702,9 @@ handle_csi(Term *t, s8 *raw)
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 'L': insert_blank_lines(t, ORONE(csi.argv[0])); break;
+ case 'M': erase_lines(t, ORONE(csi.argv[0])); break;
+ case 'P': erase_characters(t, ORONE(csi.argv[0])); break;
case 'X': erase_characters(t, ORONE(csi.argv[0])); break;
case 'Z': push_tab(t, -(ORONE(csi.argv[0]))); break;
case 'a': cursor_step_raw(t, ORONE(csi.argv[0]), 0, 1); break;