From cff5fced4ed58e1769dedce0d998000c03299cde Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 23 Apr 2020 21:50:44 -0500 Subject: [PATCH] Update: byte_dump should utilize color2 functions and handle zero-width characters --- level_3/byte_dump/c/private-byte_dump.c | 83 +++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index 59910ac..5264301 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -500,106 +500,106 @@ extern "C" { else if (output >= 0 && output <= 32 || output == 127) { if (data.presentation == byte_dump_presentation_normal) { if (output == 0) { - printf("%s", byte_dump_sequence_null); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_null); } else if (output == 1) { - printf("%s", byte_dump_sequence_start_of_header); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_start_of_header); } else if (output == 2) { - printf("%s", byte_dump_sequence_start_of_text); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_start_of_text); } else if (output == 3) { - printf("%s", byte_dump_sequence_end_of_text); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_text); } else if (output == 4) { - printf("%s", byte_dump_sequence_end_of_transmission); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_transmission); } else if (output == 5) { - printf("%s", byte_dump_sequence_end_of_enquiry); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_enquiry); } else if (output == 6) { - printf("%s", byte_dump_sequence_acknowledge); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_acknowledge); } else if (output == 7) { - printf("%s", byte_dump_sequence_bell); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_bell); } else if (output == 8) { - printf("%s", byte_dump_sequence_backspace); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_backspace); } else if (output == 9) { - printf("%s", byte_dump_sequence_tab); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_tab); } else if (output == 10) { - printf("%s", byte_dump_sequence_new_line); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_new_line); } else if (output == 11) { - printf("%s", byte_dump_sequence_tab_vertical); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_tab_vertical); } else if (output == 12) { - printf("%s", byte_dump_sequence_form_feed); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_form_feed); } else if (output == 13) { - printf("%s", byte_dump_sequence_carriage_return); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_carriage_return); } else if (output == 14) { - printf("%s", byte_dump_sequence_shift_out); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_shift_out); } else if (output == 15) { - printf("%s", byte_dump_sequence_shift_in); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_shift_in); } else if (output == 16) { - printf("%s", byte_dump_sequence_data_link_escape); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_data_link_escape); } else if (output == 17) { - printf("%s", byte_dump_sequence_device_control_1); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_1); } else if (output == 18) { - printf("%s", byte_dump_sequence_device_control_2); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_2); } else if (output == 19) { - printf("%s", byte_dump_sequence_device_control_3); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_3); } else if (output == 20) { - printf("%s", byte_dump_sequence_device_control_4); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_device_control_4); } else if (output == 21) { - printf("%s", byte_dump_sequence_negative_acknowledge); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_negative_acknowledge); } else if (output == 22) { - printf("%s", byte_dump_sequence_synchronous_idle); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_synchronous_idle); } else if (output == 23) { - printf("%s", byte_dump_sequence_end_of_transmission_block); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_transmission_block); } else if (output == 24) { - printf("%s", byte_dump_sequence_cancel); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_cancel); } else if (output == 25) { - printf("%s", byte_dump_sequence_end_of_medium); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_end_of_medium); } else if (output == 26) { - printf("%s", byte_dump_sequence_substitute); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_substitute); } else if (output == 27) { - printf("%s", byte_dump_sequence_escape); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_escape); } else if (output == 28) { - printf("%s", byte_dump_sequence_file_separator); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_file_separator); } else if (output == 29) { - printf("%s", byte_dump_sequence_group_separator); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_group_separator); } else if (output == 30) { - printf("%s", byte_dump_sequence_record_separator); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_record_separator); } else if (output == 31) { - printf("%s", byte_dump_sequence_unit_separator); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_unit_separator); } else if (output == 32) { - printf("%s", byte_dump_sequence_space); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_space); } else if (output == 127) { - printf("%s", byte_dump_sequence_delete); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_delete); } } else if (data.presentation == byte_dump_presentation_simple) { @@ -610,12 +610,23 @@ extern "C" { } } else if (f_utf_character_is_whitespace(characters.string[i]) == f_true) { - printf("%s", byte_dump_sequence_space); + fl_color_print2(f_standard_output, data.context.notable, data.context.warning, data.context.reset, "%s", byte_dump_sequence_space); + } + else if (f_utf_character_is_zero_width(characters.string[i]) == f_true) { + if (data.presentation == byte_dump_presentation_classic) { + printf("."); + } + else if (data.parameters[byte_dump_parameter_placeholder].result == f_console_result_found) { + fl_color_print(f_standard_output, data.context.warning, data.context.reset, "%s", byte_dump_character_placeholder); + } + else { + printf(" "); + } } else if (f_utf_character_is_control(characters.string[i]) == f_true) { // print a space (or '.') for control characters. if (data.presentation == byte_dump_presentation_classic) { - printf("."); + fl_color_print(f_standard_output, data.context.warning, data.context.reset, "."); } else { printf(" "); -- 1.8.3.1