summaryrefslogtreecommitdiff
path: root/src/user/highway/vars.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/highway/vars.c')
-rw-r--r--src/user/highway/vars.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/user/highway/vars.c b/src/user/highway/vars.c
index 82062c4..ed9fa3a 100644
--- a/src/user/highway/vars.c
+++ b/src/user/highway/vars.c
@@ -3,6 +3,7 @@
#include <knob/format.h>
#include <knob/block.h>
#include <knob/heap.h>
+#include <knob/rand.h>
#include <pland/pcrt.h>
@@ -80,4 +81,24 @@ void dump_vars() {
term_addf_no_ww("$%ns$\t= %ns\n", node->name.length, node->name.data, node->value.length, node->value.data);
term_paint();
}
+}
+
+static const char hex_digits[] = "0123456789abcdef";
+static char color[] = {'1', '0', '.', '.'};
+
+static const struct no_null_sn color_name = {
+ .data = "_color",
+ .length = 6
+};
+
+static const struct no_null_sn color_value = {
+ .data = color,
+ .length = 4
+};
+
+void new_color() {
+ const uint8_t bg = gen_rand() % 0x30 + 0x38;
+ color[2] = hex_digits[bg >> 4];
+ color[3] = hex_digits[bg & 0xf];
+ set_var(color_name, color_value);
} \ No newline at end of file