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 <[email protected]> 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 { 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 std::unique_ptr<ListBox> lb; 29 Sci::Position posStart; 30 Sci::Position startLen; 31 /// Should autocompletion be cancelled if editor's currentPos <= startPos? 32 bool cancelAtStartPos; 33 bool autoHide; 34 bool dropRestOfWord; 35 unsigned int ignoreCaseBehaviour; 36 int widthLBDefault; 37 int heightLBDefault; 38 /** SC_ORDER_PRESORTED: Assume the list is presorted; selection will fail if it is not alphabetical<br /> 39 * SC_ORDER_PERFORMSORT: Sort the list alphabetically; start up performance cost for sorting<br /> 40 * SC_ORDER_CUSTOM: Handle non-alphabetical entries; start up performance cost for generating a sorted lookup table 41 */ 42 int autoSort; 43 44 AutoComplete(); 45 ~AutoComplete(); 46 47 /// Is the auto completion list displayed? 48 bool Active() const noexcept; 49 50 /// Display the auto completion list positioned to be near a character position 51 void Start(Window &parent, int ctrlID, Sci::Position position, Point location, 52 Sci::Position startLen_, int lineHeight, bool unicodeMode, int technology); 53 54 /// The stop chars are characters which, when typed, cause the auto completion list to disappear 55 void SetStopChars(const char *stopChars_); 56 bool IsStopChar(char ch) const noexcept; 57 58 /// The fillup chars are characters which, when typed, fill up the selected word 59 void SetFillUpChars(const char *fillUpChars_); 60 bool IsFillUpChar(char ch) const noexcept; 61 62 /// The separator character is used when interpreting the list in SetList 63 void SetSeparator(char separator_); 64 char GetSeparator() const noexcept; 65 66 /// The typesep character is used for separating the word from the type 67 void SetTypesep(char separator_); 68 char GetTypesep() const noexcept; 69 70 /// The list string contains a sequence of words separated by the separator character 71 void SetList(const char *list); 72 73 /// Return the position of the currently selected list item 74 int GetSelection() const; 75 76 /// Return the value of an item in the list 77 std::string GetValue(int item) const; 78 79 void Show(bool show); 80 void Cancel(); 81 82 /// Move the current list element by delta, scrolling appropriately 83 void Move(int delta); 84 85 /// Select a list element that starts with word as the current element 86 void Select(const char *word); 87 }; 88 89 } 90 91 #endif 92