mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[apps/code] Handle autocomplete coloring
This commit is contained in:
@@ -19,6 +19,7 @@ constexpr KDColor KeywordColor = KDColor::RGB24(0xFF000C);
|
||||
// constexpr KDColor BuiltinColor = KDColor::RGB24(0x0086B3);
|
||||
constexpr KDColor OperatorColor = KDColor::RGB24(0xd73a49);
|
||||
constexpr KDColor StringColor = KDColor::RGB24(0x032f62);
|
||||
constexpr KDColor AutocompleteColor = KDColorRed;
|
||||
constexpr KDColor BackgroundColor = KDColorWhite;
|
||||
constexpr KDColor HighlightColor = Palette::Select;
|
||||
|
||||
@@ -160,6 +161,27 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
|
||||
mp_lexer_free(lex);
|
||||
nlr_pop();
|
||||
}
|
||||
|
||||
// Redraw the autocompleted word in the right color
|
||||
const char * autocompleteStart = m_cursorLocation;
|
||||
assert(autocompleteStart != text);
|
||||
if (m_autocomplete && autocompleteStart > text && autocompleteStart < text + byteLength) {
|
||||
const char * autocompleteEnd = cursorLocation();
|
||||
while (*autocompleteEnd != ' ' && autocompleteEnd < text + byteLength) {
|
||||
autocompleteEnd++;
|
||||
}
|
||||
drawStringAt(
|
||||
ctx,
|
||||
line,
|
||||
UTF8Helper::GlyphOffsetAtCodePoint(text, autocompleteStart),
|
||||
autocompleteStart,
|
||||
minPointer(text + byteLength, autocompleteEnd) - autocompleteStart,
|
||||
AutocompleteColor,
|
||||
BackgroundColor,
|
||||
nullptr,
|
||||
nullptr,
|
||||
HighlightColor);
|
||||
}
|
||||
}
|
||||
|
||||
KDRect PythonTextArea::ContentView::dirtyRectFromPosition(const char * position, bool includeFollowingLines) const {
|
||||
|
||||
@@ -21,7 +21,8 @@ protected:
|
||||
public:
|
||||
ContentView(App * pythonDelegate, const KDFont * font) :
|
||||
TextArea::ContentView(font),
|
||||
m_pythonDelegate(pythonDelegate)
|
||||
m_pythonDelegate(pythonDelegate),
|
||||
m_autocomplete(false)
|
||||
{
|
||||
}
|
||||
void loadSyntaxHighlighter();
|
||||
@@ -31,6 +32,7 @@ protected:
|
||||
KDRect dirtyRectFromPosition(const char * position, bool includeFollowingLines) const override;
|
||||
private:
|
||||
App * m_pythonDelegate;
|
||||
bool m_autocomplete;
|
||||
};
|
||||
private:
|
||||
const ContentView * nonEditableContentView() const override { return &m_contentView; }
|
||||
|
||||
Reference in New Issue
Block a user