From: Kevin Day Date: Sat, 27 Nov 2021 13:49:18 +0000 (-0600) Subject: Update: Make wide text display the default. X-Git-Tag: 0.5.7~74 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=8ba1139d22f143e33acfd22dd33491d1a455174f;p=fll Update: Make wide text display the default. Move the width detection into a bitwise options property. Detect the rightmost ordering of narrow and wide parameters. Set the default value to wide. --- diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index 9825f8f..38cb6ad 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -212,6 +212,31 @@ extern "C" { } } + // Identify priority of narrow and wide parameters. + { + f_console_parameter_id_t ids[2] = { byte_dump_parameter_narrow, byte_dump_parameter_wide }; + f_console_parameter_id_t choice = byte_dump_parameter_wide; + const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 2); + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true); + + byte_dump_main_delete(main); + return F_status_set_error(status); + } + + if (choice == byte_dump_parameter_narrow) { + if (main->options & byte_dump_option_wide_d) { + main->options -= byte_dump_option_wide_d; + } + } + else if (choice == byte_dump_parameter_wide) { + main->options |= byte_dump_option_wide_d; + } + } + status = F_none; } diff --git a/level_3/byte_dump/c/byte_dump.h b/level_3/byte_dump/c/byte_dump.h index c19feb2..8ca2334 100644 --- a/level_3/byte_dump/c/byte_dump.h +++ b/level_3/byte_dump/c/byte_dump.h @@ -93,6 +93,8 @@ extern "C" { byte_dump_presentation_classic, }; + #define byte_dump_option_wide_d 0x1 + #define byte_dump_sequence_acknowledge_s "␆" #define byte_dump_sequence_acknowledge_negative_s "␕" #define byte_dump_sequence_backspace_s "␈" @@ -252,6 +254,7 @@ extern "C" { uint8_t width; uint8_t mode; uint8_t presentation; + uint8_t options; f_color_context_t context; } byte_dump_main_t; @@ -268,6 +271,7 @@ extern "C" { 0, \ 0, \ 8, \ + byte_dump_option_wide_d, \ byte_dump_mode_hexidecimal, \ byte_dump_presentation_normal, \ f_color_context_t_initialize, \ diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index 8d08824..8831044 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -572,7 +572,7 @@ extern "C" { f_print_character(f_string_ascii_period_s[0], main->output.to.stream); - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } @@ -586,7 +586,7 @@ extern "C" { fl_print_format("%[%s%]", main->output.to.stream, main->context.set.warning, byte_dump_character_placeholder_s, main->context.set.warning); - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_space_s[0], main->output.to.stream); } } // for @@ -596,7 +596,7 @@ extern "C" { f_print_character(f_string_space_s[0], main->output.to.stream); - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_space_s[0], main->output.to.stream); } } // for @@ -626,7 +626,7 @@ extern "C" { fl_print_format("%[%s%]", main->output.to.stream, main->context.set.warning, byte_dump_character_placeholder_s, main->context.set.warning); } - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } } // for @@ -636,7 +636,7 @@ extern "C" { f_print_character(f_string_space_s[0], main->output.to.stream); - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_space_s[0], main->output.to.stream); } } // for @@ -660,7 +660,7 @@ extern "C" { if (invalid[i]) { fl_print_format("%[%s%]", main->output.to.stream, main->context.set.error, byte_dump_character_incomplete_s, main->context.set.error); - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } } @@ -700,7 +700,7 @@ extern "C" { fl_print_format("%]%]", main->output.to.stream, main->context.set.warning, main->context.set.notable); - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { if (f_utf_character_is_wide(characters.string[i]) != F_true) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } @@ -738,7 +738,7 @@ extern "C" { } } - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } } @@ -751,7 +751,7 @@ extern "C" { fl_print_format("%[%[%s%]%]", main->output.to.stream, main->context.set.notable, main->context.set.warning, byte_dump_sequence_space_s, main->context.set.warning, main->context.set.notable); } - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } } @@ -766,7 +766,7 @@ extern "C" { f_print_character(f_string_space_s[0], main->output.to.stream); } - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } } @@ -845,14 +845,14 @@ extern "C" { f_print_character(f_string_space_s[0], main->output.to.stream); } - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { if (width_utf == 1 || f_utf_character_is_wide(characters.string[i]) != F_true) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } } } else { - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } } @@ -860,7 +860,7 @@ extern "C" { else { f_print_character(c, main->output.to.stream); - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } } @@ -882,7 +882,7 @@ extern "C" { f_print_character(f_string_space_s[0], main->output.to.stream); } - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } @@ -904,7 +904,7 @@ extern "C" { f_print_character(f_string_space_s[0], main->output.to.stream); } - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } @@ -926,7 +926,7 @@ extern "C" { f_print_character(f_string_space_s[0], main->output.to.stream); } - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } @@ -950,7 +950,7 @@ extern "C" { fl_print_format("%[%s%]", main->output.to.stream, main->context.set.warning, byte_dump_character_placeholder_s, main->context.set.warning); } - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_ascii_space_s[0], main->output.to.stream); } } // for @@ -960,7 +960,7 @@ extern "C" { f_print_character(f_string_space_s[0], main->output.to.stream); - if (main->parameters[byte_dump_parameter_wide].result == f_console_result_found) { + if (main->options & byte_dump_option_wide_d) { f_print_character(f_string_space_s[0], main->output.to.stream); } } // for