about summary refs log tree commit diff homepage
path: root/help.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2017-07-30 16:01:46 -0400
committerJune McEnroe <june@causal.agency>2017-07-30 16:01:46 -0400
commit91b289e91d96178b25b557d008b13d977f3d4638 (patch)
treeeb443a2d6190d7d7962b66082ba4b5549dfa52d5 /help.c
parentSupport background colors (diff)
downloadtorus-91b289e91d96178b25b557d008b13d977f3d4638.tar.gz
torus-91b289e91d96178b25b557d008b13d977f3d4638.zip
Fix help to track color
Diffstat (limited to '')
-rwxr-xr-xhelp.c55
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);
 
ly with basic auth. [1]: https://palaverapp.com/guides/commands/set.html#ui-image_service 2021-09-22Remove default faviconJune McEnroe I hate these things and also this one sucks. 2021-09-21Use Z_FILTERED strategyJune McEnroe 2021-09-21Recalculate various lengths only as neededJune McEnroe This actually speeds things up quite a bit, saving roughly a second on a big PNG screenshot. Almost all the remaining time is spent in deflate. 2021-09-21Rewrite pngo, add explicit optionsJune McEnroe Interesting to see how my code habits have changed. 2021-09-16Fix /* **/ comment matchingJune McEnroe 2021-09-15Remove typer, add downgrade to READMEJune McEnroe 2021-09-15Set bot mode on downgradeJune McEnroe 2021-09-15Enter capsicum in downgradeJune McEnroe 2021-09-15Factor out common parts of downgrade messagesJune McEnroe Also bump the message cap to 1024 because that is ostensibly useful for replying to older messages. 2021-09-14Add downgrade IRC botJune McEnroe 2021-09-14Sort by title if authors matchJune McEnroe There are probably better things to sort by but title definitely always exists. 2021-09-13Swap-remove tags as they're foundJune McEnroe This makes it even faster. From ~1s on a sqlite3.c amalgamation to ~0.85s. 2021-09-12Replace htagml regex with strncmpJune McEnroe Since ctags only ever produces regular expressions of the form /^re$/ or /^re/ with no other special characters, instead unescape the pattern and simply use strncmp. Running on a sqlite3.c amalgamation, the regex version takes ~37s while the strncmp version takes ~1s, producing identical output. Big win! 2021-09-11Also defer printing comment for lone close-parensJune McEnroe 2021-09-10Publish "git-comment"June McEnroe 2021-09-10Add git comment --pretty optionJune McEnroe 2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe This fixes badly indented comments. 2021-09-08Up default min-repeat to 30 linesJune McEnroe 2021-09-08Handle dirty lines in git-commentJune McEnroe 2021-09-08Document and install git-commentJune McEnroe 2021-09-08Add repeat and all options to git-commentJune McEnroe 2021-09-08Add group threshold to git-commentJune McEnroe