parenthesis colouring in repl
This commit is contained in:
parent
a50a3bceb3
commit
0319bf6030
|
|
@ -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. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue