[apps/code] Add a setting for syntax highlighting (#85)

This commit is contained in:
Yaya-Cout
2021-11-27 12:34:09 +01:00
committed by GitHub
parent fb4b2ffdfa
commit 806b11b589
14 changed files with 38 additions and 5 deletions

View File

@@ -25,6 +25,9 @@ constexpr KDColor HighlightColor = Palette::CodeBackgroundSelected;
constexpr KDColor AutocompleteColor = KDColor::RGB24(0xC6C6C6); // TODO Palette change
static inline KDColor TokenColor(mp_token_kind_t tokenKind) {
if(!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()) {
return Palette::CodeText;
}
if (tokenKind == MP_TOKEN_STRING) {
return StringColor;
}
@@ -305,6 +308,10 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
tokenFrom += tokenLength;
KDColor color = CommentColor;
if(!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()) {
color = Palette::CodeText;
}
// Even if the token is being autocompleted, use CommentColor
if (tokenFrom < text + byteLength) {
LOG_DRAW("Draw comment \"%.*s\" from %d\n", byteLength - (tokenFrom - text), firstNonSpace, tokenFrom);
@@ -312,7 +319,7 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom),
tokenFrom,
text + byteLength - tokenFrom,
CommentColor,
color,
BackgroundColor,
selectionStart,
selectionEnd,