Live view: highlight the pointer cell instead of a caret row under it

The grid already painted the pointer cell in reverse video, and then drew a
second line under the tape with a ^^ under the same cell -- the mark said the
same thing twice on a colour terminal, and it cost the frame a line.

The caret row is gone: the cell itself is the marker.  A terminal without
colour cannot show reverse video, so in that case the cell gets a star in the
separator column it would have used anyway -- same width, no extra line, and a
redirected --dump still says where the pointer is.

    |   00E7 | 400 001 010 020 040 080 100 200 400*000 000   |    --no-color
    |   00E7 | ESC[1;7m400 ESC[0m 001 010 ...                 |    colour

Checked on the 8, 11 and 32 bit geometries and in compact mode: the frame is
one line shorter (30 lines at the default 259x11, 24 compact), every line is
still 56 characters between the bars, and there is exactly one pointer mark
per frame.  The tapes (and/or/full_adder) still print what they printed.

README: the sample frame loses the caret row (the pointer cell shows the star,
which is what a piped --dump looks like) and the frame table says how the
pointer is marked now.
This commit is contained in:
dsh committed 2026-11-07 22:47:13 +08:00
1 parent 754f885a64
commit 6e51df5240
2 files changed
+11 -34

No files matched your search

+2 -3
View File
@@ -58,8 +58,7 @@ ROT-8 ([rəʊˈteɪt]) 提供了一套简洁的指令集,使利用无ALU的各
| 20 | 01 02 04 08 10 20 40 80 01 02 04 08 10 20 40 80 |
| 30 | 01 02 04 08 10 20 40 80 01 02 04 08 10 20 40 80 |
| 40 | 01 02 04 08 10 20 40 80 01 02 04 08 10 20 40 80 |
| 50 | 01 02 04 08 10 20 40 80 01 02 10 00 00 00 00 00 |
| | ^^ |
| 50 | 01 02 04 08 10 20 40 80 01 02 10*00 00 00 00 00 |
| 60 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 70 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 80 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
@@ -82,7 +81,7 @@ ROT-8 ([rəʊˈteɪt]) 提供了一套简洁的指令集,使利用无ALU的各
| `step / pc / op` | 已经执行的指令数,程序计数器,以及 `pc` 处即将执行的指令 |
| `cell ... value` | 指针所指 Cell 的编号、十进制值与十六进制值 |
| `b7 ... b0` | 该 Cell 的各位,`#` 为 1,`.` 为 0;宽 Cell 改画一行按 4 位分组的数据 |
| 纸带 | 每行 16 个 Cell(宽 Cell 会变少),行首是十六进制地址,`^^` 标出数据指针;纸带比画面长时只画指针附近的一窗,末行注明窗口范围 |
| 纸带 | 每行 16 个 Cell(宽 Cell 会变少),行首是十六进制地址。**指针那一格反显**(终端没有颜色时,值后面跟一个 `*`,占的是它本来那个分隔空格);纸带比画面长时只画指针附近的一窗,末行注明窗口范围 |
| `out` | 到此刻为止 `OUT` 输出的值(保留最近 10 个) |
参数:
+9 -31
View File
@@ -478,46 +478,24 @@ static void viz_grid(rot8_viz *viz, rot8_iter *iter, FILE *out, bool color) {
for (col = 0; col < cols; col++) {
size_t index = base + (size_t)col;
char cell[16];
bool here;
unsigned long value;
if (index >= cells) {
line_put(&ln, " ");
continue;
}
here = (ptr >= 0 && (size_t)ptr == index);
value = (unsigned long)mem[index];
snprintf(cell, sizeof cell, "%0*lX", digits, value);
if (ptr >= 0 && (size_t)ptr == index) {
line_style(&ln, cell, ANSI_PTR);
} else {
line_style(&ln, cell, value == 0 ? ANSI_ZERO : ANSI_DATA);
}
line_put(&ln, " ");
line_style(&ln, cell, here ? ANSI_PTR
: (value == 0 ? ANSI_ZERO : ANSI_DATA));
/* The pointer cell says it in place: reverse video with colour, a
* star in the separator column without it. (The old caret row
* under the tape said the same thing a second time, and cost a
* line.) */
line_put(&ln, here && !color ? "*" : " ");
}
line_close(&ln);
/* 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. 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 = digits % 2 == 0 ? "^^" : "^";
char field[16];
int pad = digits;
if (here) {
pad = (digits - (int)strlen(mark)) / 2;
} else {
mark = "";
}
snprintf(field, sizeof field, "%*s%s ", pad, "", mark);
line_style(&ln, field, here ? ANSI_PTR : NULL);
}
line_close(&ln);
}
}
if (total_rows > shown) {