22 if (this->suggestions.empty()) {
23 this->InitSuggestions(this->textbuf->GetText());
24 if (this->suggestions.empty()) {
32 if (this->current_suggestion_index + 1 < this->suggestions.size()) {
42void AutoCompletion::Reset()
47 this->suggestions.clear();
48 this->current_suggestion_index = 0;
51void AutoCompletion::InitSuggestions(std::string_view text)
54 size_t space_pos = this->
initial_buf.find_last_of(
' ');
56 if (space_pos == std::string::npos) {
59 this->
prefix = this->
query.substr(0, space_pos + 1);
60 this->
query.remove_prefix(space_pos + 1);
64 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.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.