MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / AutoComplete

Method AutoComplete

src/autocompletion.cpp:23–44  ·  view source on GitHub ↗

* @return true, if the textbuf was updated. */

Source from the content-addressed store, hash-verified

21 * @return true, if the textbuf was updated.
22 */
23bool AutoCompletion::AutoComplete()
24{
25 /* We are pressing TAB for the first time after reset. */
26 if (this->suggestions.empty()) {
27 this->InitSuggestions(this->textbuf->GetText());
28 if (this->suggestions.empty()) {
29 return false;
30 }
31 this->ApplySuggestion(prefix, suggestions[0]);
32 return true;
33 }
34
35 /* We are pressing TAB again on the same text. */
36 if (this->current_suggestion_index + 1 < this->suggestions.size()) {
37 this->ApplySuggestion(prefix, this->suggestions[++this->current_suggestion_index]);
38 } else {
39 /* We are out of options, restore original text. */
40 this->textbuf->Assign(initial_buf);
41 this->Reset();
42 }
43 return true;
44}
45
46void AutoCompletion::Reset()
47{

Callers 2

OnKeyPressMethod · 0.80
ChatTabCompletionMethod · 0.80

Calls 7

InitSuggestionsMethod · 0.95
ResetMethod · 0.95
emptyMethod · 0.45
GetTextMethod · 0.45
ApplySuggestionMethod · 0.45
sizeMethod · 0.45
AssignMethod · 0.45

Tested by

no test coverage detected