From 8411647d92419a85ca5779ae23c6081be766ac75 Mon Sep 17 00:00:00 2001 From: xolatile Date: Tue, 12 Sep 2023 05:22:25 -0400 Subject: [PATCH] Minor updates to generally make it suck less... --- install.sh | 4 ++-- xtandard.c | 36 ++++++++++++++++++++++++++++++++++++ xtandard.h | 6 ++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 45778c8..cbf5529 100644 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ set -xe -sudo cp xtandard.h /usr/include/xolatile/xtandard.h -sudo cp xtandard.c /usr/include/xolatile/xtandard.c +cp xtandard.h /usr/include/xolatile/xtandard.h +cp xtandard.c /usr/include/xolatile/xtandard.c exit diff --git a/xtandard.c b/xtandard.c index a59ae86..01fd247 100644 --- a/xtandard.c +++ b/xtandard.c @@ -305,6 +305,17 @@ void file_export (char * name, void * data) { (void) data; } +int character_compare_array (char character, char * character_array, int count) { + int i = 0; + + do { + if (character == character_array [i]) { + return (i); + } + } while (++i != count); + + return (0); +} int string_length (char * string) { int length = 0; @@ -451,4 +462,29 @@ int string_split_space (char * string) { return (++count); } +void terminal_clear (void) { + out ("\033[2J\033[H", 7); +} + +void terminal_style (int effect, int colour) { + char format [8] = "\033[ ;3 m"; + + if ((effect == -1) || (colour == -1)) { + out ("\033[0m", 4); + } else { + format [2] = (char) effect + '0'; + format [5] = (char) colour + '0'; + + out (format, 7); + } +} + +void terminal_show_cursor (int show) { + if (show != 0) { + out ("\033[?25h", 6); + } else { + out ("\033[?25l", 6); + } +} + #endif diff --git a/xtandard.h b/xtandard.h index 1da10e6..7532a9d 100644 --- a/xtandard.h +++ b/xtandard.h @@ -78,6 +78,8 @@ extern void file_list_import (char *); extern void file_list_export (char *); extern void file_list_delete (void); +extern int character_compare_array (char, char *, int); + extern int string_length (char *); extern void string_reverse (char *); @@ -93,4 +95,8 @@ extern void string_concatenate_limit (char *, char *, int); extern int string_split_space (char *); +extern void terminal_clear (void); +extern void terminal_style (int, int); +extern void terminal_show_cursor (int); + #endif