Console rows erase to end of line
The log lines are not padded, so when a row got shorter than it had been in the previous frame (the ' ..' trim marker is three characters, a value line is more) the tail of the old row survived and read as one garbled line, e.g. '.. t> 123'. Each console row now ends with an erase-to-end-of-line when the view owns the terminal, and the frames stop leaving debris behind. Checked with ',.,.,.' fed 1 2 3 4: the trim marker shows as a clean ' ..' above the last six events, and no row carries text from the frame before it.
This commit is contained in:
1 parent
90fe5ec84a
commit
d545899107
1 file changed
+13
@@ -42,6 +42,7 @@
|
||||
#define ANSI_BIT_OFF "\x1b[90m"
|
||||
#define ANSI_OUT "\x1b[36m"
|
||||
#define ANSI_IN "\x1b[33m"
|
||||
#define ANSI_EOL "\x1b[K" /* erase to end of line */
|
||||
|
||||
#define ANSI_CLEAR "\x1b[2J\x1b[H"
|
||||
#define ANSI_HOME "\x1b[H"
|
||||
@@ -460,6 +461,15 @@ static void viz_inputs(rot8_viz *viz, FILE *out, bool color) {
|
||||
* produced, then either the prompt it is waiting on or the value it was just
|
||||
* given. The cursor is left right after "input> " so the number is typed
|
||||
* outside the window instead of in the middle of it. */
|
||||
/* console lines are not padded, so each one has to wipe the rest of its line:
|
||||
* a shorter line would otherwise leave the tail of a longer one behind and the
|
||||
* two read as a single garbled row */
|
||||
static void console_eol(rot8_viz *viz, FILE *out) {
|
||||
if (viz->tty) {
|
||||
fputs(ANSI_EOL, out);
|
||||
}
|
||||
}
|
||||
|
||||
static void viz_console(rot8_viz *viz, FILE *out, bool color) {
|
||||
size_t first, i;
|
||||
|
||||
@@ -479,6 +489,7 @@ static void viz_console(rot8_viz *viz, FILE *out, bool color) {
|
||||
if (color) {
|
||||
fputs(ANSI_RESET, out);
|
||||
}
|
||||
console_eol(viz, out);
|
||||
}
|
||||
for (i = first; i < viz->event_count; i++) {
|
||||
const struct viz_event *ev = &viz->events[i];
|
||||
@@ -491,6 +502,7 @@ static void viz_console(rot8_viz *viz, FILE *out, bool color) {
|
||||
if (color) {
|
||||
fputs(ANSI_RESET, out);
|
||||
}
|
||||
console_eol(viz, out);
|
||||
}
|
||||
if (viz->input_pending) {
|
||||
line_start(viz, out);
|
||||
@@ -501,6 +513,7 @@ static void viz_console(rot8_viz *viz, FILE *out, bool color) {
|
||||
if (color) {
|
||||
fputs(ANSI_RESET, out);
|
||||
}
|
||||
console_eol(viz, out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user