Do some simple depth highlighting in help text.

This commit is contained in:
Sage Vaillancourt 2022-03-22 11:54:26 -04:00 committed by Sage Vaillancourt
parent 5a622736d3
commit 86f3f4b32c
2 changed files with 22 additions and 4 deletions

View File

@ -278,7 +278,24 @@ char* getHelp(const char* symbol)
for (int ti = 0; ti < h.testCount; ti += 2) {
const char* test = h.tests[ti];
const char* expected = h.tests[ti + 1];
textCursor += sprintf(textCursor, "\n %s => %s", test, expected);
textCursor += sprintf(textCursor, "\n ");
int c = 0;
int depth = 0;
while(test[c]) {
if (test[c] == '(') {
depth += 1;
textCursor += sprintf(textCursor, "[3%dm", depth + 2);
} else if (test[c] == ')') {
depth -= 1;
textCursor += sprintf(textCursor, ")[3%dm", depth + 2);
c++;
continue;
}
textCursor += sprintf(textCursor, "%c", test[c]);
c++;
}
//textCursor += sprintf(textCursor, "\n %s => %s", test, expected);
textCursor += sprintf(textCursor, " => %s", expected);
}
return text;
}

View File

@ -77,9 +77,10 @@ fn(isNum, "(isnum 1) => T\n(isnum \"Hello\") => F")
(Object test, Object ignore, struct Environment* ignore2);
fn(isList,
"(islist (1 2 3)) => T\n"
"(islist ()) => T\n"
"(islist \"Stringy\") => F"
"Returns `T` only if the argument is a list.",
"(islist (1 2 3))", "T",
"(islist ())", "T",
"(islist \"Stringy\")", "F",
)(Object test, Object ignore, struct Environment* ignore2);
fn(isString,