diff options
author | Benji Dial <benji6283@gmail.com> | 2021-02-16 22:26:47 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-02-16 22:26:47 -0500 |
commit | ab4e1cfc8c587e4144d847bbd41307eff03130b2 (patch) | |
tree | 4e5502422977c747f3e65633ede26b73d9556ca1 /src/user/highway/vars.c | |
parent | 2de07a2abea4081ebab6d80729e5665ba862c74c (diff) | |
download | portland-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.c | 21 |
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 |