From 06389ac5fce485a57fbdf5809fc679aeb9ceef65 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 23 Mar 2022 01:19:13 -0400 Subject: [PATCH] Manual specification of color-highlighting order. --- src/env.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/env.c b/src/env.c index 169e8bb..ef309ba 100644 --- a/src/env.c +++ b/src/env.c @@ -269,6 +269,19 @@ struct symFunc buildFuncSym(const char* symbol, Object (* func)(Object, Object, }; } +const int black = 30; +const int red = 31; +const int green = 32; +const int yellow = 33; +const int cyan = 34; +const int purple = 35; +const int teal = 36; +const int white = 37; +const int colors[] = { + green, cyan, yellow, purple, red, white +}; +const int colorCount = array_length(colors); + char* getHelp(const char* symbol) { for (int i = 0; i < currentHelp; i++) { @@ -282,14 +295,14 @@ char* getHelp(const char* symbol) const char* expected = h.tests[ti + 1]; textCursor += sprintf(textCursor, "\n "); int c = 0; - int depth = 0; + int depth = -1; while (test[c]) { if (test[c] == '(') { depth += 1; - textCursor += sprintf(textCursor, "[3%dm", (depth % 6) + 2); + textCursor += sprintf(textCursor, "[%dm", colors[depth % colorCount]); } else if (test[c] == ')') { depth -= 1; - textCursor += sprintf(textCursor, ")[3%dm", (depth % 6) + 2); + textCursor += sprintf(textCursor, ")[%dm", colors[depth % colorCount]); c++; continue; } @@ -327,6 +340,9 @@ int runTests() struct helpText h = helpTexts[hi]; if (h.tests) { char result[1024]; + // if (h.testCount == 0) { + // printf("`%s` is untested.\n", h.symbol); + // } for (int ti = 0; ti < h.testCount; ti += 2) { const char* test = h.tests[ti]; const char* expected = h.tests[ti + 1];