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