diff --git a/clib/linenoise.c b/clib/linenoise.c index cfe51e7..5ecd64d 100644 --- a/clib/linenoise.c +++ b/clib/linenoise.c @@ -601,7 +601,21 @@ static void refreshMultiLine(struct linenoiseState *l) { unsigned int i; for (i = 0; i < l->len; i++) abAppend(&ab,"*",1); } else { - abAppend(&ab,l->buf,l->len); + int colors[] = {31, 32, 33, 35, 36}; + int nesting = 0; + for (int i = 0; i < l->len; i++) { + if (l->buf[i]=='(') { + snprintf(seq,64,"\033[%d;1m(\033[0m",colors[nesting % sizeof(colors)]); + abAppend(&ab,seq,strlen(seq)); + nesting++; + } else if (l->buf[i]==')') { + nesting--; + snprintf(seq,64,"\033[%d;1m)\033[0m",colors[nesting % sizeof(colors)]); + abAppend(&ab,seq,strlen(seq)); + } else { + abAppend(&ab,l->buf+i,1); + } + } } /* Show hits if any. */