38 lines
803 B
C
38 lines
803 B
C
#include <bshell/format.h>
|
|
#include <fx/type.h>
|
|
#include <fx/value-type.h>
|
|
|
|
#if BSHELL_INTERACTIVE == 1
|
|
#include <fx/term/print.h>
|
|
#endif
|
|
|
|
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)
|
|
{
|
|
if (fx_type_is_value_type(value->v_type)) {
|
|
format_value_fallback(value, dest);
|
|
return BSHELL_SUCCESS;
|
|
}
|
|
|
|
fx_object *object = NULL;
|
|
fx_value_get_object(value, &object);
|
|
enum bshell_status status = format_object_table(object, dest);
|
|
if (status != BSHELL_SUCCESS) {
|
|
format_value_fallback(value, dest);
|
|
}
|
|
|
|
return BSHELL_SUCCESS;
|
|
}
|