Improve handling of color mode so that applications can consistently react to the established color code.
In the fake program, this is useful for passing the color mode to the build pre-process and build post-process scripts.
#endif // _di_f_color_max_size_
#ifndef _di_f_color_types_
- typedef unsigned short f_color_id;
+ typedef uint8_t f_color_code;
- // f_color_id codes
- #define f_color_code_linux 0
- #define f_color_code_xterminal 1
+ #define f_color_code_none 0
+ #define f_color_code_linux 1
+ #define f_color_code_xterminal 2
#endif // _di_f_color_types_
/**
+ * Specify color modes.
+ *
+ * Color modes communicate how the color is supposed to be.
+ *
+ * The f_color_mode_none define designates that there is no assigned mode (the mode is undefined).
+ * The f_color_mode_no_color define designates that the color mode is set to no color (disable colors).
+ */
+#ifndef _di_f_color_mode_
+ typedef uint8_t f_color_mode;
+
+ #define f_color_mode_none 0
+ #define f_color_mode_no_color 1
+ #define f_color_mode_dark 2
+ #define f_color_mode_light 3
+#endif // _di_f_color_mode_
+
+/**
* The purpose behind these data types are not to dynamically allocate data.
* instead, they are intended to only point to existing data, so these should neither be allocated nor deallocated.
*/
if (f_status_is_not_error(status)) status = fl_macro_color_save_1(&context->notable, context->color_format, context->color_list.bold);
if (f_status_is_not_error(status)) status = fl_macro_color_save_1(&context->important, context->color_format, context->color_list.blue);
if (f_status_is_not_error(status)) status = fl_macro_color_save_1(&context->standout, context->color_format, context->color_list.purple);
+
+ context->mode = f_color_mode_light;
}
else {
status = fl_macro_color_save_1(&context->reset, context->color_format, context->color_list.reset);
if (f_status_is_not_error(status)) status = fl_macro_color_save_1(&context->notable, context->color_format, context->color_list.bold);
if (f_status_is_not_error(status)) status = fl_macro_color_save_2(&context->important, context->color_format, context->color_list.bold, context->color_list.green);
if (f_status_is_not_error(status)) status = fl_macro_color_save_1(&context->standout, context->color_format, context->color_list.green);
+
+ context->mode = f_color_mode_dark;
}
return status;
typedef struct {
f_color color_list;
f_color_format color_format;
+ f_color_mode mode;
f_string_dynamic reset;
f_string_dynamic warning;
f_string_dynamic error;
f_string_dynamic normal_reset;
} fl_color_context;
- #define fl_color_context_initialize { f_color_initialize_linux, f_color_format_initialize_linux, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize }
+ #define fl_color_context_initialize { f_color_initialize_linux, f_color_format_initialize_linux, f_color_mode_none, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize, f_string_dynamic_initialize }
#define fl_macro_color_context_new(status, color_context) \
f_macro_string_dynamic_new(status, color_context.reset, f_color_max_size + 1); \
status = fl_color_load_context(context, decision == choices.id[1]);
}
+ else {
+ context->mode = f_color_mode_no_color;
+ }
return status;
}