[apps/code] Load builtins according to autocompleted text

This commit is contained in:
Léa Saviot
2020-03-26 15:04:38 +01:00
committed by Émilie Feral
parent 1599b16e03
commit f412d95584
8 changed files with 186 additions and 131 deletions

View File

@@ -53,8 +53,13 @@ static inline size_t TokenLength(mp_lexer_t * lex, const char * tokenPosition) {
return lex->column - lex->tok_column;
}
const char * PythonTextArea::ContentView::textToAutocomplete() const {
return UTF8Helper::BeginningOfWord(editedText(), cursorLocation());
const char * PythonTextArea::ContentView::textToAutocomplete(int * length) const {
const char * result = UTF8Helper::BeginningOfWord(editedText(), cursorLocation());
if (length != nullptr) {
*length = cursorLocation() - result;
assert(*length > 0);
}
return result;
}
void PythonTextArea::ContentView::loadSyntaxHighlighter() {
@@ -235,11 +240,11 @@ bool PythonTextArea::handleEventWithText(const char * text, bool indentation, bo
return result;
}
const char * PythonTextArea::textToAutocomplete() const {
const char * PythonTextArea::textToAutocomplete(int * length) const {
if (!m_contentView.isAutocompleting()) {
return nullptr;
}
return m_contentView.textToAutocomplete();
return m_contentView.textToAutocomplete(length);
}
void PythonTextArea::removeAutocompletion() {