Manual specification of color-highlighting order.
This commit is contained in:
parent
6c7132aa46
commit
06389ac5fc
22
src/env.c
22
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];
|
||||
|
|
Loading…
Reference in New Issue