Skip to content

Commit 5c4c0e5

Browse files
authored
Added support for colored parentheses
1 parent 7564d9c commit 5c4c0e5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

apps/code/python_text_area.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,20 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
345345
// TODO: don't count Parentheses in a comment
346346
if (isOpeningBracket(lex->tok_kind)) {
347347
if (mismatched) color = KDColor::RGB24(0xFF0000);
348-
else color = matchingParenthesisColors[(bracketLineBalance + bracketBalance)% 3];
349-
bracketLineBalance++;
348+
else {
349+
color = matchingParenthesisColors[(bracketLineBalance + bracketBalance)% 3];
350+
bracketLineBalance++;
351+
}
350352
} else if (isClosingBracket(lex->tok_kind)) {
351353
bracketLineBalance--;
352354
if (mismatched) color = KDColor::RGB24(0xFF0000);
353-
else color = matchingParenthesisColors[(bracketLineBalance + bracketBalance)% 3];
355+
else {
356+
bracketLineBalance--;
357+
color = matchingParenthesisColors[(bracketLineBalance + bracketBalance)% 3];
358+
}
354359
}
355360

361+
356362
LOG_DRAW("Draw \"%.*s\" for token %d\n", tokenLength, tokenFrom, lex->tok_kind);
357363
drawStringAt(ctx, line,
358364
UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom),

0 commit comments

Comments
 (0)