b32 print_function_mappings : 1;
b32 print_static_if_results : 1;
b32 print_notes : 1;
+ b32 no_colors : 1;
b32 use_post_mvp_features : 1;
#private_file
adjust_slider_value :: #match {
- @Incomplete // the step parameter is ignored.
- // Integers need to be
(value: ^i32, x: f32, width: f32, min_value: i32, max_value: i32) {
step_width := width / ~~math.abs(max_value - min_value);
percent := (x + step_width / 2) / width;
*value = math.clamp(*value, min_value, max_value);
},
- @Incomplete // the step parameter is ignored.
(value: ^$T, x: f32, width: f32, min_value: T, max_value: T) {
percent := x / width;
*value = math.lerp(percent, min_value, max_value);
"\t--print-function-mappings Prints a mapping from WASM function index to source location.\n"
"\t--print-static-if-results Prints the conditional result of each #if statement. Useful for debugging.\n"
"\t--print-notes Prints the location of notes throughout the loaded code.\n"
+ "\t--no-colors Disables colors in the error message\n"
"\n";
else if (!strcmp(argv[i], "--print-notes")) {
options.print_notes = 1;
}
+ else if (!strcmp(argv[i], "--no-colors")) {
+ options.no_colors = 1;
+ }
else if (!strcmp(argv[i], "--use-post-mvp-features")) {
options.use_post_mvp_features = 1;
}
static void print_detailed_message(OnyxError* err, bh_file_contents* fc) {
bh_printf("(%s:%l,%l) %s\n", err->pos.filename, err->pos.line, err->pos.column, err->text);
+ b32 colored_printing = 0;
+ #ifdef _BH_LINUX
+ colored_printing = !context.options->no_colors;
+ #endif
+
i32 linelength = 0;
char* walker = err->pos.line_start;
while (*walker != '\n') linelength++, walker++;
+ if (colored_printing) bh_printf("\033[90m");
i32 numlen = bh_printf(" %d | ", err->pos.line);
+ if (colored_printing) bh_printf("\033[94m");
bh_printf("%b\n", err->pos.line_start, linelength);
char* pointer_str = bh_alloc_array(global_scratch_allocator, char, linelength + numlen);
pointer_str[err->pos.column + numlen - 2] = '^';
pointer_str[err->pos.column + numlen + err->pos.length - 1] = 0;
+ if (colored_printing) bh_printf("\033[91m");
bh_printf("%s\n", pointer_str);
+
+ if (colored_printing) bh_printf("\033[97m");
}
void onyx_errors_print() {