From 2615a3b9f21701866bfc4bdf9df24044587a6e92 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 18 Jan 2021 00:32:39 -0800 Subject: Hacky fix for tabs misaligning error printing --- files.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'files.c') 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"); } -- cgit v1.2.3