Do some simple depth highlighting in help text.
This commit is contained in:
parent
5a622736d3
commit
86f3f4b32c
19
src/env.c
19
src/env.c
|
@ -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 [1m=>[0m %s", test, expected);
|
||||
textCursor += sprintf(textCursor, " [0m[1m=>[0m %s", expected);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue