aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/aec/aec.c17
-rw-r--r--lib/aec/aec.h14
-rw-r--r--lib/io/Makefile2
-rw-r--r--lib/io/io.c19
-rwxr-xr-xlib/io/testbin20240 -> 26504 bytes
5 files changed, 48 insertions, 4 deletions
diff --git a/lib/aec/aec.c b/lib/aec/aec.c
index d38e8d1..92a1f08 100644
--- a/lib/aec/aec.c
+++ b/lib/aec/aec.c
@@ -12,6 +12,23 @@ void sgr(const char *attrs)
}
+void foreground(const char *code)
+{
+ csi();
+ wstd("3");
+ wstd(code);
+ wstd("m");
+}
+
+
+void background(const char *code)
+{
+ csi();
+ wstd("4");
+ wstd(code);
+ wstd("m");
+}
+
#ifdef AEC_UNIT_TEST
int main() {
diff --git a/lib/aec/aec.h b/lib/aec/aec.h
index f304175..70c2706 100644
--- a/lib/aec/aec.h
+++ b/lib/aec/aec.h
@@ -1,6 +1,8 @@
#ifndef AEC_H
#define AEC_H
+#include "../sys/sizes.h"
+
#define SGR_RESET "0"
#define SGR_BOLD "1"
#define SGR_FAINT "2"
@@ -24,4 +26,16 @@
void sgr(const char *attrs);
+#define COLOR_BLACK "0"
+#define COLOR_RED "1"
+#define COLOR_GREEN "2"
+#define COLOR_YELLOW "3"
+#define COLOR_BLUE "4"
+#define COLOR_PINK "5"
+#define COLOR_CYAN "6"
+#define COLOR_WHITE "7"
+
+void foreground(const char *code);
+void background(const char *code);
+
#endif
diff --git a/lib/io/Makefile b/lib/io/Makefile
index e60a656..73aa785 100644
--- a/lib/io/Makefile
+++ b/lib/io/Makefile
@@ -1,3 +1,3 @@
unit_test:
- gcc io.c ../cstr/cstr.c ../sys/start.S -o test -static -nostdlib -fno-stack-protector -Wno-implicit-function-declaration -g
+ gcc io.c ../aec/aec.c ../cstr/cstr.c ../env/env.c ../sys/start.S -o test -static -nostdlib -fno-stack-protector -Wno-implicit-function-declaration -DIO_LIB_UNIT_TEST -g
./test
diff --git a/lib/io/io.c b/lib/io/io.c
index 160b4cb..3b0ea96 100644
--- a/lib/io/io.c
+++ b/lib/io/io.c
@@ -1,6 +1,7 @@
#include "io.h"
#include "../cstr/cstr.h"
+#include "../aec/aec.h"
void __wstdn(const char *buf, u64 n)
{
@@ -33,7 +34,20 @@ void wstdf__(const char *buf, const void **args)
case '%': __wstdn("%", 1); break;
case 's':
__wstdn(((const char **)args)[0], cstr_length(((const char**)args)[0]));
- ++args; break;
+ ++args;
+ break;
+ case 'S':
+ sgr(((const char **)args)[0]);
+ ++args;
+ break;
+ case 'F':
+ foreground(((const char **)args)[0]);
+ ++args;
+ break;
+ case 'B':
+ background(((const char **)args)[0]);
+ ++args;
+ break;
}
start = buf + 1;
@@ -46,7 +60,6 @@ void wstdf__(const char *buf, const void **args)
#ifdef IO_LIB_UNIT_TEST
int main() {
- void *args[] = { "hallo", "welt" };
- wstdf__("%s %s\n", args);
+ wstdf("%s %S%F%s%S\n", "hallo", SGR_UNDERLINE, COLOR_RED, "welt", SGR_RESET);
}
#endif
diff --git a/lib/io/test b/lib/io/test
index 560b047..b2a3047 100755
--- a/lib/io/test
+++ b/lib/io/test
Binary files differ