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