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) {
|
for (int ti = 0; ti < h.testCount; ti += 2) {
|
||||||
const char* test = h.tests[ti];
|
const char* test = h.tests[ti];
|
||||||
const char* expected = h.tests[ti + 1];
|
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;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,9 +77,10 @@ fn(isNum, "(isnum 1) => T\n(isnum \"Hello\") => F")
|
||||||
(Object test, Object ignore, struct Environment* ignore2);
|
(Object test, Object ignore, struct Environment* ignore2);
|
||||||
|
|
||||||
fn(isList,
|
fn(isList,
|
||||||
"(islist (1 2 3)) => T\n"
|
"Returns `T` only if the argument is a list.",
|
||||||
"(islist ()) => T\n"
|
"(islist (1 2 3))", "T",
|
||||||
"(islist \"Stringy\") => F"
|
"(islist ())", "T",
|
||||||
|
"(islist \"Stringy\")", "F",
|
||||||
)(Object test, Object ignore, struct Environment* ignore2);
|
)(Object test, Object ignore, struct Environment* ignore2);
|
||||||
|
|
||||||
fn(isString,
|
fn(isString,
|
||||||
|
|
Loading…
Reference in New Issue