diff options
author | June McEnroe <june@causal.agency> | 2017-07-30 16:01:46 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2017-07-30 16:01:46 -0400 |
commit | 91b289e91d96178b25b557d008b13d977f3d4638 (patch) | |
tree | eb443a2d6190d7d7962b66082ba4b5549dfa52d5 | |
parent | Support background colors (diff) | |
download | torus-91b289e91d96178b25b557d008b13d977f3d4638.tar.gz torus-91b289e91d96178b25b557d008b13d977f3d4638.zip |
Fix help to track color
-rwxr-xr-x | help.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/help.c b/help.c index 8360143..40c7adb 100755 --- a/help.c +++ b/help.c @@ -13,6 +13,16 @@ exec cc -Wall -Wextra -pedantic $@ -o help $0 static int client; +static uint8_t color = COLOR_WHITE; + +static void white(void) { + color = COLOR_WHITE; +} + +static void brite(void) { + color = COLOR_BRIGHT | COLOR_WHITE; +} + static void clientMessage(const struct ClientMessage *msg) { ssize_t len = send(client, msg, sizeof(*msg), 0); if (len < 0) err(EX_IOERR, "send"); @@ -25,15 +35,10 @@ static void clientMove(int8_t dx, int8_t dy) { clientMessage(&msg); } -static void clientColor(uint8_t color) { - struct ClientMessage msg = { .type = CLIENT_COLOR }; - msg.data.c = color; - clientMessage(&msg); -} - static void clientPut(char cell) { struct ClientMessage msg = { .type = CLIENT_PUT }; - msg.data.p = cell; + msg.data.p.color = color; + msg.data.p.cell = cell; clientMessage(&msg); } @@ -64,14 +69,6 @@ static void clear(uint8_t width, uint8_t height) { clientMove(-x, -height); } -static void white(void) { - clientColor(COLOR_WHITE); -} - -static void brite(void) { - clientColor(COLOR_BRIGHT | COLOR_WHITE); -} - static int8_t lineLen; static void string(const char *str) { @@ -165,20 +162,20 @@ int main() { enter(); clientMove(13, -6); - clientColor(COLOR_RED); mvPut(0, 0, '1'); - clientColor(COLOR_GREEN); mvPut(0, 1, '2'); - clientColor(COLOR_YELLOW); mvPut(0, 1, '3'); - clientColor(COLOR_BLUE); mvPut(0, 1, '4'); - clientColor(COLOR_MAGENTA); mvPut(0, 1, '5'); - clientColor(COLOR_CYAN); mvPut(0, 1, '6'); - clientColor(COLOR_WHITE); mvPut(0, 1, '7'); - clientColor(COLOR_BRIGHT | COLOR_WHITE); mvPut(2, 0, '&'); - clientColor(COLOR_BRIGHT | COLOR_CYAN); mvPut(0, -1, '^'); - clientColor(COLOR_BRIGHT | COLOR_MAGENTA); mvPut(0, -1, '%'); - clientColor(COLOR_BRIGHT | COLOR_BLUE); mvPut(0, -1, '$'); - clientColor(COLOR_BRIGHT | COLOR_YELLOW); mvPut(0, -1, '#'); - clientColor(COLOR_BRIGHT | COLOR_GREEN); mvPut(0, -1, '@'); - clientColor(COLOR_BRIGHT | COLOR_RED); mvPut(0, -1, '!'); + color = COLOR_RED; mvPut(0, 0, '1'); + color = COLOR_GREEN; mvPut(0, 1, '2'); + color = COLOR_YELLOW; mvPut(0, 1, '3'); + color = COLOR_BLUE; mvPut(0, 1, '4'); + color = COLOR_MAGENTA; mvPut(0, 1, '5'); + color = COLOR_CYAN; mvPut(0, 1, '6'); + color = COLOR_WHITE; mvPut(0, 1, '7'); + color = COLOR_BRIGHT | COLOR_WHITE; mvPut(2, 0, '&'); + color = COLOR_BRIGHT | COLOR_CYAN; mvPut(0, -1, '^'); + color = COLOR_BRIGHT | COLOR_MAGENTA; mvPut(0, -1, '%'); + color = COLOR_BRIGHT | COLOR_BLUE; mvPut(0, -1, '$'); + color = COLOR_BRIGHT | COLOR_YELLOW; mvPut(0, -1, '#'); + color = COLOR_BRIGHT | COLOR_GREEN; mvPut(0, -1, '@'); + color = COLOR_BRIGHT | COLOR_RED; mvPut(0, -1, '!'); clientMove(-26, -3); |