From 92f101e5001ce70879ccbbfd91cd1135d5b82fda Mon Sep 17 00:00:00 2001 From: Max Wash Date: Thu, 8 May 2025 22:24:50 +0100 Subject: [PATCH] diag: adjust pretty print formatting --- diag/write/pretty.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/diag/write/pretty.c b/diag/write/pretty.c index 534cb03..a518903 100644 --- a/diag/write/pretty.c +++ b/diag/write/pretty.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -136,9 +137,18 @@ static void print_msg( struct ivy_diag_ctx *ctx, struct ivy_diag *diag, struct diag_c_msg *msg, struct ivy_diag_stream *stream) { - diag_stream_puts(stream, " "); - diag_stream_puts(stream, msg->msg_content); - diag_stream_putc(stream, '\n'); + if (stream->s_type == IVY_DIAG_STREAM_TTY) { + b_paragraph_format format = { + .p_left_margin = 2, + .p_right_margin = 2, + }; + + b_print_paragraph(msg->msg_content, stream->s_tty, &format); + } else { + diag_stream_puts(stream, " "); + diag_stream_puts(stream, msg->msg_content); + diag_stream_putc(stream, '\n'); + } } static bool highlight_contains_cell( @@ -375,10 +385,8 @@ static void update_underline(struct snippet_print_ctx *ctx) switch (ctx->ctx_hl->h_type) { case IVY_DIAG_HIGHLIGHT_ERROR: case IVY_DIAG_HIGHLIGHT_WARNING: - b_stringstream_add(&ctx->ctx_underline, "^"); - break; case IVY_DIAG_HIGHLIGHT_HINT: - b_stringstream_add(&ctx->ctx_underline, "-"); + b_stringstream_add(&ctx->ctx_underline, "^"); break; default: b_stringstream_add(&ctx->ctx_underline, " "); @@ -393,7 +401,7 @@ static void write_underline(struct snippet_print_ctx *ctx) } STREAM_COLOUR_ACCENT(ctx->ctx_stream); - diag_stream_puts(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); diag_stream_putc(ctx->ctx_stream, '\n');