From de5cb6be426ec03a67e9a3e2b1bd3606c7cafe13 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Fri, 9 May 2025 13:40:09 +0100 Subject: [PATCH] diag: fix pretty write_underline writing line margin in bold --- diag/write/pretty.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/diag/write/pretty.c b/diag/write/pretty.c index a518903..7bd9c3c 100644 --- a/diag/write/pretty.c +++ b/diag/write/pretty.c @@ -33,11 +33,12 @@ struct snippet_print_ctx { const struct ivy_diag_amendment *ctx_amendment; }; -#define __STREAM_COLOUR_ERROR "[red,bold]" -#define __STREAM_COLOUR_WARN "[yellow,bold]" -#define __STREAM_COLOUR_HINT "[blue,bold]" -#define __STREAM_COLOUR_ACCENT "[cyan]" -#define __STREAM_COLOUR_RESET "[reset]" +#define __STREAM_COLOUR_ERROR "[red,bold]" +#define __STREAM_COLOUR_WARN "[yellow,bold]" +#define __STREAM_COLOUR_HINT "[blue,bold]" +#define __STREAM_COLOUR_LINE_NO "[cyan]" +#define __STREAM_COLOUR_ACCENT "[cyan]" +#define __STREAM_COLOUR_RESET "[reset]" #define STREAM_COLOUR_ERROR(stream) \ if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \ @@ -55,6 +56,10 @@ struct snippet_print_ctx { if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \ diag_stream_puts(stream, __STREAM_COLOUR_ACCENT); \ } +#define STREAM_COLOUR_LINE_NO(stream) \ + if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \ + diag_stream_puts(stream, __STREAM_COLOUR_LINE_NO); \ + } #define STREAM_COLOUR_RESET(stream) \ if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \ diag_stream_puts(stream, __STREAM_COLOUR_RESET); \ @@ -400,7 +405,8 @@ static void write_underline(struct snippet_print_ctx *ctx) return; } - STREAM_COLOUR_ACCENT(ctx->ctx_stream); + STREAM_COLOUR_RESET(ctx->ctx_stream); + STREAM_COLOUR_LINE_NO(ctx->ctx_stream); diag_stream_puts(ctx->ctx_stream, " : "); diag_stream_puts(ctx->ctx_stream, ctx->ctx_underline_buf); STREAM_COLOUR_RESET(ctx->ctx_stream); @@ -421,7 +427,7 @@ static void print_snippet( for (unsigned long row = snippet->s_first_line; row <= snippet->s_last_line; row++) { - STREAM_COLOUR_ACCENT(stream); + STREAM_COLOUR_LINE_NO(stream); diag_stream_printf(stream, " %4lu | ", row); printer.ctx_row = row;