Manual specification of color-highlighting order.

This commit is contained in:
Sage Vaillancourt 2022-03-23 01:19:13 -04:00 committed by Sage Vaillancourt
parent 6c7132aa46
commit 06389ac5fc
1 changed files with 19 additions and 3 deletions

View File

@ -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];