[apps/code] Load varbox before returning it in console

This commit is contained in:
Léa Saviot
2020-04-30 10:37:24 +02:00
committed by Émilie Feral
parent d1c8bbdaf7
commit ac654f0097
4 changed files with 25 additions and 16 deletions

View File

@@ -159,9 +159,7 @@ int VariableBoxController::typeAtLocation(int i, int j) {
void VariableBoxController::loadFunctionsAndVariables(int scriptIndex, const char * textToAutocomplete, int textToAutocompleteLength) {
// Reset the node counts
m_currentScriptNodesCount = 0;
m_builtinNodesCount = 0;
m_importedNodesCount = 0;
empty();
if (scriptIndex < 0) {
/* If not script index is given, the variable box is loaded from console. We
@@ -241,6 +239,16 @@ const char * VariableBoxController::autocompletionAlternativeAtIndex(int textToA
return currentName + textToAutocompleteLength;
}
void VariableBoxController::loadVariablesImportedFromScripts() {
const int scriptsCount = m_scriptStore->numberOfScripts();
for (int i = 0; i < scriptsCount; i++) {
Script script = m_scriptStore->scriptAtIndex(i);
if (script.contentFetchedFromConsole()) {
loadGlobalAndImportedVariablesInScriptAsImported(script.fullName(), script.scriptContent(), nullptr, -1, false); // TODO optimize number of script fetches
}
}
}
void VariableBoxController::empty() {
m_builtinNodesCount = 0;
m_currentScriptNodesCount = 0;
@@ -382,16 +390,6 @@ void VariableBoxController::insertTextInCaller(const char * text, int textLength
sender()->handleEventWithText(commandBuffer);
}
void VariableBoxController::loadVariablesImportedFromScripts() {
const int scriptsCount = m_scriptStore->numberOfScripts();
for (int i = 0; i < scriptsCount; i++) {
Script script = m_scriptStore->scriptAtIndex(i);
if (script.contentFetchedFromConsole()) {
loadGlobalAndImportedVariablesInScriptAsImported(script.fullName(), script.scriptContent(), nullptr, -1, false); // TODO optimize number of script fetches
}
}
}
void VariableBoxController::loadBuiltinNodes(const char * textToAutocomplete, int textToAutocompleteLength) {
//TODO LEA could be great to use strings defined in STATIC const char *const tok_kw[] from python/lexer.c
//TODO LEA Prune these (check all are usable in our Python, but just comment those which aren't -> there might become usable later)