| 1 | // Scintilla source code edit control |
| 2 | /** @file AutoComplete.h |
| 3 | ** Defines the auto completion list box. |
| 4 | **/ |
| 5 | // Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org> |
| 6 | // The License.txt file describes the conditions under which this software may be distributed. |
| 7 | |
| 8 | #ifndef AUTOCOMPLETE_H |
| 9 | #define AUTOCOMPLETE_H |
| 10 | |
| 11 | namespace Scintilla::Internal { |
| 12 | |
| 13 | /** |
| 14 | */ |
| 15 | class AutoComplete { |
| 16 | bool active; |
| 17 | std::string stopChars; |
| 18 | std::string fillUpChars; |
| 19 | char separator; |
| 20 | char typesep; // Type separator |
| 21 | enum { maxItemLen=1000 }; |
| 22 | std::vector<int> sortMatrix; |
| 23 | |
| 24 | public: |
| 25 | |
| 26 | bool ignoreCase; |
| 27 | bool chooseSingle; |
| 28 | AutoCompleteOption options; |
| 29 | std::unique_ptr<ListBox> lb; |
| 30 | Sci::Position posStart; |
| 31 | Sci::Position startLen; |
| 32 | /// Should autocompletion be cancelled if editor's currentPos <= startPos? |
| 33 | bool cancelAtStartPos; |
| 34 | bool autoHide; |
| 35 | bool dropRestOfWord; |
| 36 | Scintilla::CaseInsensitiveBehaviour ignoreCaseBehaviour; |
| 37 | int widthLBDefault; |
| 38 | int heightLBDefault; |
| 39 | /** Ordering::PreSorted: Assume the list is presorted; selection will fail if it is not alphabetical<br /> |
| 40 | * Ordering::PerformSort: Sort the list alphabetically; start up performance cost for sorting<br /> |
| 41 | * Ordering::Custom: Handle non-alphabetical entries; start up performance cost for generating a sorted lookup table |
| 42 | */ |
| 43 | Scintilla::Ordering autoSort; |
| 44 | |
| 45 | AutoComplete(); |
| 46 | // Deleted so AutoComplete objects can not be copied. |
| 47 | AutoComplete(const AutoComplete &) = delete; |
| 48 | AutoComplete(AutoComplete &&) = delete; |
| 49 | AutoComplete &operator=(const AutoComplete &) = delete; |
| 50 | AutoComplete &operator=(AutoComplete &&) = delete; |
| 51 | ~AutoComplete(); |
| 52 | |
| 53 | /// Is the auto completion list displayed? |
| 54 | bool Active() const noexcept; |
| 55 | |
| 56 | /// Display the auto completion list positioned to be near a character position |
| 57 | void Start(Window &parent, int ctrlID, Sci::Position position, Point location, |
| 58 | Sci::Position startLen_, int lineHeight, bool unicodeMode, Scintilla::Technology technology, |
| 59 | ListOptions listOptions); |
| 60 | |
| 61 | /// The stop chars are characters which, when typed, cause the auto completion list to disappear |
| 62 | void SetStopChars(const char *stopChars_); |
| 63 | bool IsStopChar(char ch) const noexcept; |
| 64 | |
| 65 | /// The fillup chars are characters which, when typed, fill up the selected word |
| 66 | void SetFillUpChars(const char *fillUpChars_); |
| 67 | bool IsFillUpChar(char ch) const noexcept; |
| 68 | |
| 69 | /// The separator character is used when interpreting the list in SetList |
| 70 | void SetSeparator(char separator_); |
| 71 | char GetSeparator() const noexcept; |
| 72 | |
| 73 | /// The typesep character is used for separating the word from the type |
| 74 | void SetTypesep(char separator_); |
| 75 | char GetTypesep() const noexcept; |
| 76 | |
| 77 | /// The list string contains a sequence of words separated by the separator character |
| 78 | void SetList(const char *list); |
| 79 | |
| 80 | /// Return the position of the currently selected list item |
| 81 | int GetSelection() const; |
| 82 | |
| 83 | /// Return the value of an item in the list |
| 84 | std::string GetValue(int item) const; |
| 85 | |
| 86 | void Show(bool show); |
| 87 | void Cancel() noexcept; |
| 88 | |
| 89 | /// Move the current list element by delta, scrolling appropriately |
| 90 | void Move(int delta); |
| 91 | |
| 92 | /// Select a list element that starts with word as the current element |
| 93 | void Select(const char *word); |
| 94 | }; |
| 95 | |
| 96 | } |
| 97 | |
| 98 | #endif |
| 99 | |