mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/code] Add a setting for syntax highlighting (#85)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user