]> Kevux Git Server - fll/commitdiff
Update: Make wide text display the default.
authorKevin Day <thekevinday@gmail.com>
Sat, 27 Nov 2021 13:49:18 +0000 (07:49 -0600)
committerKevin Day <thekevinday@gmail.com>
Sat, 27 Nov 2021 13:49:18 +0000 (07:49 -0600)
Move the width detection into a bitwise options property.
Detect the rightmost ordering of narrow and wide parameters.
Set the default value to wide.

level_3/byte_dump/c/byte_dump.c
level_3/byte_dump/c/byte_dump.h
level_3/byte_dump/c/private-byte_dump.c

index 9825f8f13daa934a1845caf17d172d3826ce0f54..38cb6ad1b1cb4cc635662c8642fb575af5f109f5 100644 (file)
@@ -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;
     }
 
index c19feb293611dcc6b9705e44ce08d3d42c54ad93..8ca233468829b2a3f8525ba6cd999d02434e81c3 100644 (file)
@@ -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, \
index 8d08824edfd854d5422fc171a4a1346ce19331a0..88310443684c55fe7c01dca8be2771d9bf68070a 100644 (file)
@@ -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