26 if (this->suggestions.empty()) {
27 this->InitSuggestions(this->textbuf->GetText());
28 if (this->suggestions.empty()) {
36 if (this->current_suggestion_index + 1 < this->suggestions.size()) {
46void AutoCompletion::Reset()
51 this->suggestions.clear();
52 this->current_suggestion_index = 0;
55void AutoCompletion::InitSuggestions(std::string_view text)
58 size_t space_pos = this->
initial_buf.find_last_of(
' ');
60 if (space_pos == std::string::npos) {
63 this->
prefix = this->
query.substr(0, space_pos + 1);
64 this->
query.remove_prefix(space_pos + 1);
68 this->current_suggestion_index = 0;
Generic auto-completion engine.
virtual std::vector< std::string > GetSuggestions(std::string_view prefix, std::string_view query)=0
Get suggestions for auto completion with the given 'query' input text.
virtual void ApplySuggestion(std::string_view prefix, std::string_view suggestion)=0
Format the given suggestion after the given prefix, and write that to the buffer.
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.