term: implement platform-independent console text colour/formatting

This commit is contained in:
2024-11-14 22:01:40 +00:00
parent b260159fae
commit 9ac204e84e
5 changed files with 347 additions and 25 deletions

View File

@@ -38,7 +38,24 @@ static unsigned int extract_line(
unsigned int i;
for (i = 0; start[i]; i++) {
if (start[i] == '\033') {
while (!isalpha(start[i++])) {
while (start[i] && !isalpha(start[i])) {
delta++;
i++;
}
delta++;
}
if (start[i] == '[') {
if (start[i + 1] == '[') {
delta++;
i++;
continue;
}
while (start[i] && start[i] != ']') {
i++;
delta++;
}
@@ -137,7 +154,8 @@ static b_status print_paragraph_tty(
indent(format, fp, left_margin, false);
}
b_fprintf(fp, "%s\n", b_string_ptr(line));
b_fputs(b_string_ptr(line), fp);
fputc('\n', fp);
need_indent = true;
}