]> git.saurik.com Git - wxWidgets.git/blame - src/stc/scintilla/src/AutoComplete.cxx
Don't call busy cursor when creating a message
[wxWidgets.git] / src / stc / scintilla / src / AutoComplete.cxx
CommitLineData
9ce192d4
RD
1// Scintilla source code edit control
2// AutoComplete.cxx - defines the auto completion list box
3// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
4// The License.txt file describes the conditions under which this software may be distributed.
5
6#include <stdlib.h>
7#include <string.h>
8
9#include "Platform.h"
10
11#include "AutoComplete.h"
12
d134f170
RD
13AutoComplete::AutoComplete() :
14 active(false),
15 separator(' '),
16 ignoreCase(false),
17 chooseSingle(false),
18 posStart(0),
19 startLen(0),
20 cancelAtStartPos(true) {
21 stopChars[0] = '\0';
22 fillUpChars[0] = '\0';
9ce192d4
RD
23}
24
25AutoComplete::~AutoComplete() {
26 lb.Destroy();
27}
28
29bool AutoComplete::Active() {
30 return active;
31}
32
33void AutoComplete::Start(Window &parent, int ctrlID, int position, int startLen_) {
34 if (!lb.Created()) {
35 lb.Create(parent, ctrlID);
36 }
37 lb.Clear();
38 active = true;
39 startLen = startLen_;
40 posStart = position;
41}
42
43void AutoComplete::SetStopChars(const char *stopChars_) {
44 strncpy(stopChars, stopChars_, sizeof(stopChars));
45 stopChars[sizeof(stopChars) - 1] = '\0';
46}
47
48bool AutoComplete::IsStopChar(char ch) {
49 return ch && strchr(stopChars, ch);
50}
51
d134f170
RD
52void AutoComplete::SetFillUpChars(const char *fillUpChars_) {
53 strncpy(fillUpChars, fillUpChars_, sizeof(fillUpChars));
54 fillUpChars[sizeof(fillUpChars) - 1] = '\0';
55}
56
57bool AutoComplete::IsFillUpChar(char ch) {
58 return ch && strchr(fillUpChars, ch);
59}
60
f6bcfd97
BP
61void AutoComplete::SetSeparator(char separator_) {
62 separator = separator_;
63}
64
65char AutoComplete::GetSeparator() {
66 return separator;
67}
68
d134f170 69void AutoComplete::SetList(const char *list) {
9ce192d4
RD
70 lb.Clear();
71 char *words = new char[strlen(list) + 1];
72 if (words) {
73 strcpy(words, list);
74 char *startword = words;
75 int i = 0;
76 for (; words && words[i]; i++) {
f6bcfd97 77 if (words[i] == separator) {
9ce192d4
RD
78 words[i] = '\0';
79 lb.Append(startword);
9ce192d4
RD
80 startword = words + i + 1;
81 }
82 }
83 if (startword) {
84 lb.Append(startword);
9ce192d4
RD
85 }
86 delete []words;
87 }
88 lb.Sort();
9ce192d4
RD
89}
90
91void AutoComplete::Show() {
92 lb.Show();
93 lb.Select(0);
94}
95
96void AutoComplete::Cancel() {
97 if (lb.Created()) {
98 lb.Destroy();
9ce192d4
RD
99 active = false;
100 }
101}
102
103
104void AutoComplete::Move(int delta) {
105 int count = lb.Length();
106 int current = lb.GetSelection();
107 current += delta;
108 if (current >= count)
109 current = count - 1;
110 if (current < 0)
111 current = 0;
112 lb.Select(current);
113}
114
115void AutoComplete::Select(const char *word) {
116 int pos = lb.Find(word);
117 //Platform::DebugPrintf("Autocompleting at <%s> %d\n", wordCurrent, pos);
118 if (pos != -1)
119 lb.Select(pos);
120}
121