multi: completely remove fx.term dependency when interactive support is disabled
This commit is contained in:
@@ -15,7 +15,14 @@ endforeach (d)
|
||||
|
||||
add_library(bshell.runtime SHARED ${sources})
|
||||
|
||||
target_link_libraries(bshell.runtime FX::Runtime FX::Collections FX::Term)
|
||||
target_link_libraries(bshell.runtime FX::Runtime FX::Collections)
|
||||
|
||||
if (bshell_interactive)
|
||||
target_link_libraries(bshell.runtime FX::Term)
|
||||
endif ()
|
||||
|
||||
target_include_directories(bshell.runtime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_compile_definitions(bshell.runtime PUBLIC
|
||||
BSHELL_VERSION="${bshell_version}")
|
||||
BSHELL_VERSION="${bshell_version}"
|
||||
BSHELL_INTERACTIVE=${bshell_interactive}
|
||||
BSHELL_VERBOSE=${bshell_verbose})
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -116,12 +116,17 @@ static enum bshell_status resolve_call_target(
|
||||
}
|
||||
|
||||
const char *cmd_name_cstr = fx_string_get_cstr(cmd_name_s);
|
||||
fx_printf(
|
||||
"[bold,bright_red]%s: The term '%s' is not recognised as a "
|
||||
"name of a cmdlet, "
|
||||
"function, script file, or executable program.[reset]\n",
|
||||
cmd_name_cstr,
|
||||
cmd_name_cstr);
|
||||
#if BSHELL_INTERACTIVE == 1
|
||||
fx_printf("[bold,bright_red]");
|
||||
#endif
|
||||
printf("%s: The term '%s' is not recognised as a name of a cmdlet, "
|
||||
"function, script file, or executable program.\n",
|
||||
cmd_name_cstr,
|
||||
cmd_name_cstr);
|
||||
#if BSHELL_INTERACTIVE == 1
|
||||
fx_printf("[reset]");
|
||||
#endif
|
||||
printf("\n");
|
||||
return BSHELL_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user