2023-11-04 14:55:48 -04:00
|
|
|
#include <xolatile/xtandard.c>
|
|
|
|
|
|
|
|
static void echo_line (void) {
|
2024-01-03 06:42:23 -05:00
|
|
|
terminal_colour (colour_grey, effect_bold);
|
2023-11-04 14:55:48 -04:00
|
|
|
|
|
|
|
echo (" | ");
|
|
|
|
|
|
|
|
terminal_cancel ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void echo_base (int character, int base, int colour, int effect) {
|
|
|
|
echo_line ();
|
|
|
|
|
|
|
|
terminal_colour (colour, effect);
|
|
|
|
|
|
|
|
if (base == 2) {
|
|
|
|
echo (format_to_string (character, 0, base, 7, '0'));
|
|
|
|
} else if (base == 8) {
|
|
|
|
echo (format_to_string (character, 0, base, 3, '0'));
|
|
|
|
} else if (base == 16) {
|
|
|
|
echo (format_to_string (character, 0, base, 2, '0'));
|
|
|
|
} else {
|
|
|
|
echo (format_to_string (character, 0, base, 3, ' '));
|
|
|
|
}
|
|
|
|
|
|
|
|
terminal_cancel ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void echo_code (int character, int colour, int effect) {
|
|
|
|
char * code [32] = {
|
|
|
|
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
|
|
|
|
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"
|
|
|
|
};
|
|
|
|
|
|
|
|
echo_line ();
|
|
|
|
|
|
|
|
terminal_colour (colour, effect);
|
|
|
|
|
2024-01-03 06:42:23 -05:00
|
|
|
if (character == signal_delete) {
|
2023-11-04 14:55:48 -04:00
|
|
|
echo ("DEL");
|
|
|
|
} else if (character_is_invisible (character) != 0) {
|
|
|
|
echo (code [character]);
|
|
|
|
if (string_length (code [character]) == 2) {
|
|
|
|
echo (" ");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
out (& character, 1);
|
|
|
|
echo (" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
terminal_cancel ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void echo_name (int character, int colour, int effect) {
|
|
|
|
char * name [128] = {
|
|
|
|
"Null", "Start of heading", "Start of text", "End of text",
|
|
|
|
"End of transmission", "Enquiry", "Acknowledge", "Bell",
|
|
|
|
"Backspace", "Horizontal tab", "Line feed", "Vertical tab",
|
|
|
|
"Form feed", "Carriage return", "Shift out", "Shift in",
|
|
|
|
"Data link escape", "Device control 1", "Device control 2", "Device control 3",
|
|
|
|
"Device control 4", "Negative acknowledge", "Synchronous idle", "End transmission block",
|
|
|
|
"Cancel", "End of medium", "Substitute", "Escape",
|
|
|
|
"File separator", "Group separator", "Record separator", "Unit separator",
|
|
|
|
"Space", "Exclamation mark", "Speech mark", "Number sign",
|
|
|
|
"Dollar sign", "Percent", "Ampersand", "Quote",
|
|
|
|
"Open parenthesis", "Close parenthesis", "Asterisk", "Plus",
|
|
|
|
"Comma", "Minus", "Period", "Slash",
|
|
|
|
"Zero", "One", "Two", "Three",
|
|
|
|
"Four", "Five", "Six", "Seven",
|
|
|
|
"Eight", "Nine", "Colon", "Semicolon",
|
|
|
|
"Open angled bracket", "Equal", "Close angled bracket", "Question mark",
|
|
|
|
"At sign", "Uppercase A", "Uppercase B", "Uppercase C",
|
|
|
|
"Uppercase D", "Uppercase E", "Uppercase F", "Uppercase G",
|
|
|
|
"Uppercase H", "Uppercase I", "Uppercase J", "Uppercase K",
|
|
|
|
"Uppercase L", "Uppercase M", "Uppercase N", "Uppercase O",
|
|
|
|
"Uppercase P", "Uppercase Q", "Uppercase R", "Uppercase S",
|
|
|
|
"Uppercase T", "Uppercase U", "Uppercase V", "Uppercase W",
|
|
|
|
"Uppercase X", "Uppercase Y", "Uppercase Z", "Opening bracket",
|
|
|
|
"Backslash", "Closing bracket", "Caret", "Underscore",
|
|
|
|
"Grave", "Lowercase a", "Lowercase b", "Lowercase c",
|
|
|
|
"Lowercase d", "Lowercase e", "Lowercase f", "Lowercase g",
|
|
|
|
"Lowercase h", "Lowercase i", "Lowercase j", "Lowercase k",
|
|
|
|
"Lowercase l", "Lowercase m", "Lowercase n", "Lowercase o",
|
|
|
|
"Lowercase p", "Lowercase q", "Lowercase r", "Lowercase s",
|
|
|
|
"Lowercase t", "Lowercase u", "Lowercase v", "Lowercase w",
|
|
|
|
"Lowercase x", "Lowercase y", "Lowercase z", "Opening brace",
|
|
|
|
"Vertical bar", "Closing brace", "Tilde", "Delete"
|
|
|
|
};
|
|
|
|
|
|
|
|
echo_line ();
|
|
|
|
|
|
|
|
terminal_colour (colour, effect);
|
|
|
|
|
|
|
|
echo (name [character]);
|
|
|
|
|
2024-02-23 14:16:09 -05:00
|
|
|
out (" ", 24 - string_length (name [character])); /* L: */
|
2023-11-04 14:55:48 -04:00
|
|
|
|
|
|
|
terminal_cancel ();
|
|
|
|
}
|
|
|
|
|
|
|
|
int main (void) {
|
|
|
|
int character;
|
|
|
|
|
|
|
|
for (character = 0; character != 128; ++character) {
|
2024-01-03 06:42:23 -05:00
|
|
|
echo_base (character, 2, colour_white, effect_normal);
|
|
|
|
echo_base (character, 8, colour_cyan, effect_normal);
|
|
|
|
echo_base (character, 10, colour_cyan, effect_italic);
|
|
|
|
echo_base (character, 16, colour_cyan, effect_bold);
|
|
|
|
echo_code (character, colour_blue, effect_bold);
|
|
|
|
echo_name (character, colour_pink, effect_normal);
|
2023-11-04 14:55:48 -04:00
|
|
|
|
|
|
|
if (character % 2 != 0) {
|
|
|
|
echo ("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-03 06:42:23 -05:00
|
|
|
return (0);
|
2023-11-04 14:55:48 -04:00
|
|
|
}
|