summaryrefslogtreecommitdiff
path: root/src/user/highway/vars.c
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-02-16 22:26:47 -0500
committerBenji Dial <benji6283@gmail.com>2021-02-16 22:26:47 -0500
commitab4e1cfc8c587e4144d847bbd41307eff03130b2 (patch)
tree4e5502422977c747f3e65633ede26b73d9556ca1 /src/user/highway/vars.c
parent2de07a2abea4081ebab6d80729e5665ba862c74c (diff)
downloadportland-os-ab4e1cfc8c587e4144d847bbd41307eff03130b2.tar.gz
rtc timestamp, knob rand, random terminal color
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