diag: adjust pretty print formatting

This commit is contained in:
2025-05-08 22:24:50 +01:00
parent 592acc693f
commit 92f101e500

View File

@@ -5,6 +5,7 @@
#include <assert.h> #include <assert.h>
#include <blue/core/stringstream.h> #include <blue/core/stringstream.h>
#include <blue/term/print.h>
#include <blue/term/tty.h> #include <blue/term/tty.h>
#include <ctype.h> #include <ctype.h>
#include <ivy/line-source.h> #include <ivy/line-source.h>
@@ -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_ctx *ctx, struct ivy_diag *diag, struct diag_c_msg *msg,
struct ivy_diag_stream *stream) struct ivy_diag_stream *stream)
{ {
diag_stream_puts(stream, " "); if (stream->s_type == IVY_DIAG_STREAM_TTY) {
diag_stream_puts(stream, msg->msg_content); b_paragraph_format format = {
diag_stream_putc(stream, '\n'); .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( static bool highlight_contains_cell(
@@ -375,10 +385,8 @@ static void update_underline(struct snippet_print_ctx *ctx)
switch (ctx->ctx_hl->h_type) { switch (ctx->ctx_hl->h_type) {
case IVY_DIAG_HIGHLIGHT_ERROR: case IVY_DIAG_HIGHLIGHT_ERROR:
case IVY_DIAG_HIGHLIGHT_WARNING: case IVY_DIAG_HIGHLIGHT_WARNING:
b_stringstream_add(&ctx->ctx_underline, "^");
break;
case IVY_DIAG_HIGHLIGHT_HINT: case IVY_DIAG_HIGHLIGHT_HINT:
b_stringstream_add(&ctx->ctx_underline, "-"); b_stringstream_add(&ctx->ctx_underline, "^");
break; break;
default: default:
b_stringstream_add(&ctx->ctx_underline, " "); 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); 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); diag_stream_puts(ctx->ctx_stream, ctx->ctx_underline_buf);
STREAM_COLOUR_RESET(ctx->ctx_stream); STREAM_COLOUR_RESET(ctx->ctx_stream);
diag_stream_putc(ctx->ctx_stream, '\n'); diag_stream_putc(ctx->ctx_stream, '\n');