multi: completely remove fx.term dependency when interactive support is disabled

This commit is contained in:
2026-05-30 21:08:39 +01:00
parent ca33228e0e
commit 338c0356ca
9 changed files with 223 additions and 119 deletions
+6
View File
@@ -5,9 +5,15 @@
static void format_value_fallback(const fx_value *value, fx_stream *dest)
{
#if BSHELL_INTERACTIVE == 1
fx_printf("[yellow]");
#endif
fx_value_to_string(value, dest, NULL);
#if BSHELL_INTERACTIVE == 1
fx_printf("[reset]\n");
#endif
}
enum bshell_status format_value_default(const fx_value *value, fx_stream *dest)
+26 -4
View File
@@ -137,10 +137,14 @@ enum bshell_status bshell_table_ctx_prepare_columns_from_format(
ctx->ctx_columns = columns;
ctx->ctx_columns_count = fmt->fmt_column_count;
ctx->ctx_tty_width = 0;
#if BSHELL_INTERACTIVE == 1
fx_tty_get_dimensions(fx_stdtty, &ctx->ctx_tty_width, NULL);
#endif
if (!ctx->ctx_tty_width) {
ctx->ctx_tty_width = 150;
ctx->ctx_tty_width = 80;
}
ctx->ctx_variable_columns_count = 0;
@@ -208,10 +212,14 @@ enum bshell_status bshell_table_ctx_prepare_columns_from_object(
ctx->ctx_columns = columns;
ctx->ctx_columns_count = column_count;
ctx->ctx_tty_width = 0;
#if BSHELL_INTERACTIVE == 1
fx_tty_get_dimensions(fx_stdtty, &ctx->ctx_tty_width, NULL);
#endif
if (!ctx->ctx_tty_width) {
ctx->ctx_tty_width = 150;
ctx->ctx_tty_width = 80;
}
ctx->ctx_variable_columns_count = 0;
@@ -232,9 +240,23 @@ enum bshell_status bshell_table_ctx_prepare_columns_from_object(
return BSHELL_SUCCESS;
}
static void set_table_header_tty_colour(void)
{
#if BSHELL_INTERACTIVE == 1
fx_printf("[bold,bright_green]");
#endif
}
static void reset_tty_colour(void)
{
#if BSHELL_INTERACTIVE == 1
fx_printf("[reset]");
#endif
}
enum bshell_status bshell_table_ctx_print_headers(struct bshell_table_ctx *ctx)
{
fx_printf("[bold,bright_green]");
set_table_header_tty_colour();
bool repeat = false;
struct bshell_table_ctx_column *c = NULL;
@@ -293,7 +315,7 @@ enum bshell_status bshell_table_ctx_print_headers(struct bshell_table_ctx *ctx)
}
}
fx_printf("[reset]");
reset_tty_colour();
fx_stream_write_char(ctx->ctx_out, '\n');
return BSHELL_SUCCESS;
}