OpenTTD Source: AutoCompletion Class Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
AutoCompletion Class Referenceabstract
Inheritance diagram for AutoCompletion:

## Public Member Functions
| AutoCompletion (Textbuf *textbuf)
bool | AutoComplete ()
void | Reset ()

## Protected Attributes
Textbuf * | textbuf

## Private Member Functions
void | InitSuggestions (std::string_view text)
virtual std::vector< std::string > | GetSuggestions (std::string_view prefix, std::string_view query)=0
virtual void | ApplySuggestion (std::string_view prefix, std::string_view suggestion)=0

## Private Attributes
std::string | initial_buf
| Value of text buffer when we started current suggestion session.
std::string_view | prefix
| Prefix of the text before the last space.
std::string_view | query
| Last token of the text. This is used to based the suggestions on.
std::vector< std::string > | suggestions
size_t | current_suggestion_index

## Detailed Description

Definition at line 15 of file autocompletion.h.

## Constructor & Destructor Documentation

## ◆ AutoCompletion()

AutoCompletion::AutoCompletion | ( | Textbuf * | textbuf | ) |
| inline

Definition at line 29 of file autocompletion.h.

## Member Function Documentation

## ◆ AutoComplete()

bool AutoCompletion::AutoComplete | ( |  | ) |

Returns
  true, if the textbuf was updated.

Definition at line 23 of file autocompletion.cpp.

References Textbuf::Assign(), Textbuf::GetText(), initial_buf, and prefix.

Referenced by NetworkChatWindow::ChatTabCompletion().

## ◆ InitSuggestions()

void AutoCompletion::InitSuggestions | ( | std::string_view | text | ) |
| private

Definition at line 55 of file autocompletion.cpp.

## ◆ Reset()

void AutoCompletion::Reset | ( |  | ) |

Definition at line 46 of file autocompletion.cpp.

## Field Documentation

## ◆ current_suggestion_index

size_t AutoCompletion::current_suggestion_index
| private

Definition at line 26 of file autocompletion.h.

## ◆ initial_buf

std::string AutoCompletion::initial_buf
| private

Value of text buffer when we started current suggestion session.

Definition at line 20 of file autocompletion.h.

Referenced by AutoComplete().

## ◆ prefix

std::string_view AutoCompletion::prefix
| private

Prefix of the text before the last space.

Definition at line 22 of file autocompletion.h.

Referenced by AutoComplete().

## ◆ query

std::string_view AutoCompletion::query
| private

Last token of the text. This is used to based the suggestions on.

Definition at line 23 of file autocompletion.h.

## ◆ suggestions

std::vector<std::string> AutoCompletion::suggestions
| private

Definition at line 25 of file autocompletion.h.

## ◆ textbuf

Textbuf* AutoCompletion::textbuf
| protected

Definition at line 17 of file autocompletion.h.

The documentation for this class was generated from the following files:

- src/autocompletion.h
- src/autocompletion.cpp