Commit: 49a37f7810f1bd42c2f6cc1f9cd6c59a1d117030
Parent: ee916f134c6c34eb080b89ece95aba84d48d58f3
Author: Randy Palamar
Date: Thu, 23 Jan 2025 06:32:26 -0700
terminal: support DECST8C
This is useful for testing since it resets all tabstops to be 8 wide.
Diffstat:
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/terminal.c b/terminal.c
@@ -387,7 +387,8 @@ next_tab_position(Term *t, b32 backwards)
u32 zeroes = clz_u32(t->tabs[idx--] & mask);
while (idx < ARRAY_COUNT(t->tabs) && zeroes == 32)
zeroes = clz_u32(t->tabs[idx--]);
- result = 32 * (idx + 1) + 32 - zeroes;
+ result = 32 * (idx + 1) + 32 - zeroes;
+ result *= col != 0;
} else {
u32 zeroes = ctz_u32(t->tabs[idx++] & ~mask);
while (idx < ARRAY_COUNT(t->tabs) && zeroes == 32)
@@ -412,6 +413,15 @@ term_tab_col(Term *t, u32 col, b32 set)
}
static void
+reset_tabs(Term *t, u32 column_step)
+{
+ for (u32 i = 0; i < ARRAY_COUNT(t->tabs); i++)
+ t->tabs[i] = 0;
+ for (u32 i = column_step; i < t->size.w; i += column_step)
+ term_tab_col(t, i, 1);
+}
+
+static void
term_reset(Term *t)
{
i32 mode = t->mode.term & TM_ALTSCREEN;
@@ -426,10 +436,7 @@ term_reset(Term *t)
swap_screen(t);
fb_clear_region(t, 0, t->size.h, 0, t->size.w);
}
- for (u32 i = 0; i < ARRAY_COUNT(t->tabs); i++)
- t->tabs[i] = 0;
- for (u32 i = g_tabstop; i < t->size.w; i += g_tabstop)
- term_tab_col(t, i, 1);
+ reset_tabs(t, g_tabstop);
t->top = 0;
t->bot = t->size.h - 1;
@@ -935,6 +942,7 @@ handle_csi(Term *t, CSI *csi)
case 'X': erase_characters(t, ORONE(csi->argv[0])); break;
case 'S': fb_scroll_up(t, t->top, ORONE(csi->argv[0])); break;
case 'T': fb_scroll_down(t, t->top, ORONE(csi->argv[0])); break;
+ case 'W': if (csi->priv) reset_tabs(t, 8); else goto unknown; break;
case 'Z': push_tab(t, -(ORONE(csi->argv[0]))); break;
case 'a': cursor_step_raw(t, ORONE(csi->argv[0]), 0, 1); break;
case 'd': cursor_move_abs_to(t, csi->argv[0] - 1, p.x); break;