diff --git a/src/scene/gui/textinputnode.cpp b/src/scene/gui/textinputnode.cpp index 6629855..33f2121 100644 --- a/src/scene/gui/textinputnode.cpp +++ b/src/scene/gui/textinputnode.cpp @@ -182,7 +182,7 @@ std::string TextInputNode::getText() void TextInputNode::clearText() { m_history.push_back(m_text); - m_history_pos++; + m_history_pos=m_history.size(); m_text.clear(); } diff --git a/src/sparrowshell/sparrowshell.cpp b/src/sparrowshell/sparrowshell.cpp index 1d51954..9d6abf9 100644 --- a/src/sparrowshell/sparrowshell.cpp +++ b/src/sparrowshell/sparrowshell.cpp @@ -73,22 +73,28 @@ void SparrowShell::AutocompletionCallBack::exec(){ std::vector results = m_shell->m_script->possibleCompletion(text); if (!results.empty()){ - std:: string common_prefix = results[0]; - for( auto result : results){ - int i = 0; - auto s1 = common_prefix.c_str(); - auto s2 = result.c_str(); - std::string cp; - while( (s1[i] && s2[i]) && (s1[i] == s2[i]) ) - cp.push_back(s1[i++]); - common_prefix = cp; + if(results.size() == 1){ + std::string text = results[0]; + text+="()"; + m_text_input_node->setText(text); + }else{ + std:: string common_prefix = results[0]; + for( auto result : results){ + int i = 0; + auto s1 = common_prefix.c_str(); + auto s2 = result.c_str(); + std::string cp; + while( (s1[i] && s2[i]) && (s1[i] == s2[i]) ) + cp.push_back(s1[i++]); + common_prefix = cp; + } + m_text_input_node->setText(common_prefix); + std::string output = ""; + for(std::string& fun : results) + output+=fun+" "; + m_shell->out(output,glm::vec3(1,1,0)); } - m_text_input_node->setText(common_prefix); } - std::string output = ""; - for(std::string& fun : results) - output+=fun+" "; - m_shell->out(output,glm::vec3(1,1,0)); } void SparrowShell::InputCallBack::exec(){ diff --git a/src/test/main.cpp b/src/test/main.cpp index 7584e85..864f7aa 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -438,13 +438,8 @@ int main(){ }*/ // shell output tests - engine.getShell()->out("Hello World!"); - engine.getShell()->out("Starting test :"); - - -// engine.getScene()->updateShaders(); -// BackGroundNode* bgrn = new BackGroundNode(glm::vec2(10),glm::vec3(1.,1.,1.),1,1); -// engine.getScene()->getRootObject()->addChild(bgrn); +// engine.getShell()->out("Hello World!"); +// engine.getShell()->out("Starting test :"); // preparing shaders and launching the engine engine.start();