From a210ed152734ec2fb57a234149c9a7bd041aadcf Mon Sep 17 00:00:00 2001 From: xolatile Date: Sat, 4 Nov 2023 14:55:48 -0400 Subject: [PATCH] Pushing pretty much finished program... --- README.md | 20 ++++++++++- compile.sh | 7 ++++ install.sh | 7 ++++ xscii.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 compile.sh create mode 100644 install.sh create mode 100644 xscii.c diff --git a/README.md b/README.md index 3cf2821..350f5c5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ # xscii -I don't even know... \ No newline at end of file +xscii -- Program for seeing ASCII table, if you want to change output style, do it in source. + +- Everything related to my libraries is clean of all warning options on Clang, GCC and Valgrind. +- I don't know what else to write here, program is being done in my free time, so expect more... + +Compile: +```bash +$ sh compile.sh +``` + +Install: +```bash +$ sudo sh install.sh +``` + +Use: +```bash +$ xscii +``` diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..3712b69 --- /dev/null +++ b/compile.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -xe + +gcc -g -ansi -Wall -Wextra -Wpedantic -Werror -Ofast -o xscii xscii.c + +exit diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..1853706 --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -xe + +cp xscii /usr/bin/xscii + +exit diff --git a/xscii.c b/xscii.c new file mode 100644 index 0000000..c279b19 --- /dev/null +++ b/xscii.c @@ -0,0 +1,118 @@ +#include + +static void echo_line (void) { + terminal_colour (COLOUR_GREY, EFFECT_BOLD); + + 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); + + if (character == SIGNAL_DELETE) { + 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]); + + out (" ", 40 - string_length (name [character])); + + terminal_cancel (); +} + +int main (void) { + int character; + + for (character = 0; character != 128; ++character) { + 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); + + if (character % 2 != 0) { + echo ("\n"); + } + } + + return (EXIT_SUCCESS); +}