20bool AutoCompletion::AutoComplete()
23 if (this->suggestions.empty()) {
24 this->InitSuggestions(this->textbuf->
buf);
25 if (this->suggestions.empty()) {
28 this->ApplySuggestion(
prefix, suggestions[0]);
33 if (this->current_suggestion_index + 1 < this->suggestions.size()) {
34 this->ApplySuggestion(
prefix, this->suggestions[++this->current_suggestion_index]);
43void AutoCompletion::Reset()
48 this->suggestions.clear();
49 this->current_suggestion_index = 0;
52void AutoCompletion::InitSuggestions(std::string_view text)
55 size_t space_pos = this->
initial_buf.find_last_of(
' ');
57 if (space_pos == std::string::npos) {
60 this->
prefix = this->
query.substr(0, space_pos + 1);
61 this->
query.remove_prefix(space_pos + 1);
64 this->suggestions = this->GetSuggestions(
prefix,
query);
65 this->current_suggestion_index = 0;
Generic auto-completion engine.
std::string_view query
Last token of the text. This is used to based the suggestions on.
std::string_view prefix
Prefix of the text before the last space.
std::string initial_buf
Value of text buffer when we started current suggestion session.
Internally used functions for the console.
Base core network types and some helper functions to access them.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
void Assign(StringID string)
Render a string into the textbuffer.
char *const buf
buffer in which text is saved