aboutsummaryrefslogtreecommitdiff
path: root/include/kpl
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-09-16 16:23:05 -0400
committernodist <kevin.comas.git@gmail.com>2026-09-16 16:23:05 -0400
commit349fe86e9b6e8cdfec43bfaaf7f4691b4f7b1cd9 (patch)
tree8e6fe5b11e0d0b95328c0a0a17225f2de84f008f /include/kpl
parent63cc458fc3d0df10c91ca5c859a656845d27a8ad (diff)
fix .gitignore
Diffstat (limited to 'include/kpl')
-rw-r--r--include/kpl/color.h119
-rw-r--r--include/kpl/system.h10
-rw-r--r--include/kpl/type.h29
3 files changed, 158 insertions, 0 deletions
diff --git a/include/kpl/color.h b/include/kpl/color.h
new file mode 100644
index 0000000..1f77dcb
--- /dev/null
+++ b/include/kpl/color.h
@@ -0,0 +1,119 @@
+
+#pragma once
+
+// C string pretty printing macros
+
+#define KPL_COLOR_CONCAT(COLOR) KPL_COLOR_ ## COLOR
+
+#ifndef KPL_COLOR_OFF
+
+#define KPL_COLOR(A) "\e[" KPL_COLOR_CONCAT(A) "m"
+#define KPL_COLOR2(A, B) "\e[" KPL_COLOR_CONCAT(A) ";" KPL_COLOR_CONCAT(B) "m"
+#define KPL_COLOR3(A, B, C) "\e[" KPL_COLOR_CONCAT(A) ";" KPL_COLOR_CONCAT(B) ";" KPL_COLOR_CONCAT(C) "m"
+
+#define KPL_COLOR_RESET "0"
+#define KPL_COLOR_BOLD "1"
+#define KPL_COLOR_FAINT "2"
+#define KPL_COLOR_ITALIC "3"
+#define KPL_COLOR_UNDERLINE "4"
+#define KPL_COLOR_BLINK "5"
+#define KPL_COLOR_REVERSE "7"
+#define KPL_COLOR_HIDDEN "8"
+#define KPL_COLOR_RESET_BOLD "21"
+#define KPL_COLOR_RESET_FAINT "22"
+#define KPL_COLOR_RESET_ITALIC "23"
+#define KPL_COLOR_RESET_UNDERLINE "24"
+#define KPL_COLOR_RESET_BLINK "25"
+#define KPL_COLOR_RESET_REVERSE "27"
+#define KPL_COLOR_RESET_HIDDEN "28"
+#define KPL_COLOR_BLACK "30"
+#define KPL_COLOR_RED "31"
+#define KPL_COLOR_GREEN "32"
+#define KPL_COLOR_YELLOW "33"
+#define KPL_COLOR_BLUE "34"
+#define KPL_COLOR_MAGENTA "35"
+#define KPL_COLOR_CYAN "36"
+#define KPL_COLOR_GREY "37"
+#define KPL_COLOR_DEFAULT "39"
+#define KPL_COLOR_BG_BLACK "30"
+#define KPL_COLOR_BG_RED "41"
+#define KPL_COLOR_BG_GREEN "42"
+#define KPL_COLOR_BG_YELLOW "43"
+#define KPL_COLOR_BG_BLUE "44"
+#define KPL_COLOR_BG_MAGENTA "45"
+#define KPL_COLOR_BG_CYAN "46"
+#define KPL_COLOR_BG_GREY "47"
+#define KPL_COLOR_DARK_GREY "90"
+#define KPL_COLOR_LIGHT_RED "91"
+#define KPL_COLOR_LIGHT_GREEN "92"
+#define KPL_COLOR_LIGHT_YELLOW "93"
+#define KPL_COLOR_LIGHT_BLUE "94"
+#define KPL_COLOR_LIGHT_MAGENTA "95"
+#define KPL_COLOR_LIGHT_CYAN "96"
+#define KPL_COLOR_WHITE "97"
+#define KPL_COLOR_BG_DARK_GREY "100"
+#define KPL_COLOR_BG_LIGHT_RED "101"
+#define KPL_COLOR_BG_LIGHT_GREEN "102"
+#define KPL_COLOR_BG_LIGHT_YELLOW "103"
+#define KPL_COLOR_BG_LIGHT_BLUE "104"
+#define KPL_COLOR_BG_LIGHT_MAGENTA "105"
+#define KPL_COLOR_BG_LIGHT_CYAN "106"
+#define KPL_COLOR_BG_WHITE "107"
+
+#else
+
+#define KPL_COLOR(A) KPL_COLOR_CONCAT(A)
+#define KPL_COLOR2(A, B) KPL_COLOR_CONCAT(A) KPL_COLOR_CONCAT(B)
+#define KPL_COLOR3(A, B, C) KPL_COLOR_CONCAT(A) KPL_COLOR_CONCAT(B) KPL_COLOR_CONCAT(C)
+
+
+#define KPL_COLOR_RESET ""
+#define KPL_COLOR_BOLD ""
+#define KPL_COLOR_FAINT ""
+#define KPL_COLOR_ITALIC ""
+#define KPL_COLOR_UNDERLINE ""
+#define KPL_COLOR_BLINK ""
+#define KPL_COLOR_REVERSE ""
+#define KPL_COLOR_HIDDEN ""
+#define KPL_COLOR_RESET_BOLD ""
+#define KPL_COLOR_RESET_FAINT ""
+#define KPL_COLOR_RESET_ITALIC ""
+#define KPL_COLOR_RESET_UNDERLINE ""
+#define KPL_COLOR_RESET_BLINK ""
+#define KPL_COLOR_RESET_REVERSE ""
+#define KPL_COLOR_RESET_HIDDEN ""
+#define KPL_COLOR_BLACK ""
+#define KPL_COLOR_RED ""
+#define KPL_COLOR_GREEN ""
+#define KPL_COLOR_YELLOW ""
+#define KPL_COLOR_BLUE ""
+#define KPL_COLOR_MAGENTA ""
+#define KPL_COLOR_CYAN ""
+#define KPL_COLOR_GREY ""
+#define KPL_COLOR_DEFAULT ""
+#define KPL_COLOR_BG_BLACK ""
+#define KPL_COLOR_BG_RED ""
+#define KPL_COLOR_BG_GREEN ""
+#define KPL_COLOR_BG_YELLOW ""
+#define KPL_COLOR_BG_BLUE ""
+#define KPL_COLOR_BG_MAGENTA ""
+#define KPL_COLOR_BG_CYAN ""
+#define KPL_COLOR_BG_GREY ""
+#define KPL_COLOR_DARK_GREY ""
+#define KPL_COLOR_LIGHT_RED ""
+#define KPL_COLOR_LIGHT_GREEN ""
+#define KPL_COLOR_LIGHT_YELLOW ""
+#define KPL_COLOR_LIGHT_BLUE ""
+#define KPL_COLOR_LIGHT_MAGENTA ""
+#define KPL_COLOR_LIGHT_CYAN ""
+#define KPL_COLOR_WHITE ""
+#define KPL_COLOR_BG_DARK_GREY ""
+#define KPL_COLOR_BG_LIGHT_RED ""
+#define KPL_COLOR_BG_LIGHT_GREEN ""
+#define KPL_COLOR_BG_LIGHT_YELLOW ""
+#define KPL_COLOR_BG_LIGHT_BLUE ""
+#define KPL_COLOR_BG_LIGHT_MAGENTA ""
+#define KPL_COLOR_BG_LIGHT_CYAN ""
+#define KPL_COLOR_BG_WHITE ""
+
+#endif
diff --git a/include/kpl/system.h b/include/kpl/system.h
new file mode 100644
index 0000000..f7d8239
--- /dev/null
+++ b/include/kpl/system.h
@@ -0,0 +1,10 @@
+
+#pragma once
+
+// System headers and miscellaneous utilities
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
diff --git a/include/kpl/type.h b/include/kpl/type.h
new file mode 100644
index 0000000..b18f6ae
--- /dev/null
+++ b/include/kpl/type.h
@@ -0,0 +1,29 @@
+
+#pragma once
+
+// KPL specific types
+
+#include "system.h"
+
+typedef enum : int32_t {
+ KPL_EXIT_CODE_SUCCESS = 0,
+ KPL_EXIT_CODE_ERROR = 1,
+ KPL_EXIT_CODE_HELP = 2
+} kpl_exit_code;
+
+typedef uint8_t kpl_utf8[4];
+
+typedef union {
+ uint8_t u8;
+ int8_t i8;
+ uint16_t u16;
+ int16_t i16;
+ uint32_t u32;
+ int32_t i32;
+ uint64_t u64;
+ int64_t i64;
+ kpl_utf8 utf8;
+ float f32;
+ double f64;
+ void *ptr;
+} kpl_value;