diag: adjust pretty print formatting
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/term/print.h>
|
||||
#include <blue/term/tty.h>
|
||||
#include <ctype.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_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');
|
||||
|
||||
Reference in New Issue
Block a user