Centre the caret inside the cell it points at

This commit is contained in:
dsh committed 2026-11-07 11:20:11 +08:00
1 parent 83f18d46bb
commit 348e64ec97
1 file changed
+8 -8
+8 -8
View File
@@ -494,22 +494,22 @@ static void viz_grid(rot8_viz *viz, rot8_iter *iter, FILE *out, bool color) {
/* A caret under the tape pointer, for terminals without colour. One
* field is digits + 1 characters wide, exactly like a hex cell, or the
* caret walks left of its cell as the columns add up. */
* caret walks left of its cell as the columns add up. The mark sits in
* the middle of the digits: two carets for an even digit count, one for
* an odd one, so it stays centred instead of leaning to one side. */
if (ptr >= 0 && (size_t)ptr / (size_t)cols == first_row + row) {
line_open(&ln, viz, out, color);
snprintf(label, sizeof label, "%*s| ", addr + 3, "");
line_put(&ln, label);
for (col = 0; col < cols; col++) {
bool here = (size_t)ptr == base + (size_t)col;
const char *mark = "";
const char *mark = digits % 2 == 0 ? "^^" : "^";
char field[16];
int pad;
int pad = digits;
if (here) {
mark = digits > 1 ? "^^" : "^";
}
pad = digits - (int)strlen(mark);
if (pad < 0) {
pad = 0;
pad = (digits - (int)strlen(mark)) / 2;
} else {
mark = "";
}
snprintf(field, sizeof field, "%*s%s ", pad, "", mark);
line_style(&ln, field, here ? ANSI_PTR : NULL);