aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-18 00:32:39 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-18 00:32:39 -0800
commit2615a3b9f21701866bfc4bdf9df24044587a6e92 (patch)
tree46f852bfec72a5a6a2678e1085d4f9918d6bd48b
parentdfdc7bf94a6ec3e5362eb2982d5c5c31edee4239 (diff)
Hacky fix for tabs misaligning error printing
-rw-r--r--files.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/files.c b/files.c
index f6c1c1f..145d1c1 100644
--- a/files.c
+++ b/files.c
@@ -228,11 +228,16 @@ void fprint_line(FILE *dest, file_t *f, const char *start, const char *end, cons
(int)charnum - 1, line,
(int)(end - &line[charnum-1]), &line[charnum-1],
(int)(eol - end - 1), end);
- fprintf(dest, " \033[34;1m");
- const char *p = line - 1;
- for (; p < start; ++p) fputc(' ', dest);
+ fprintf(dest, " \033[34;1m");
+ const char *p = line;
+ for (; p < start; ++p) fputc(*p == '\t' ? '\t' : ' ', dest);
if (start == end) ++end;
- for (; p < end; ++p) fputc('^', dest);
+ for (; p < end; ++p)
+ if (*p == '\t')
+ // Some janky hacks: 8 ^'s, backtrack 8 spaces, move forward a tab stop, clear any ^'s that overshot
+ fprintf(dest, "^^^^^^^^\033[8D\033[I\033[K");
+ else
+ fputc('^', dest);
fprintf(dest, "\033[0m\n");
}