diff options
author | nyamatongwe <unknown> | 2001-08-02 13:31:30 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2001-08-02 13:31:30 +0000 |
commit | 7b098a59967555b13d083970731c55ca13c87491 (patch) | |
tree | ab92e8c7b96a4df90df025a6a920983d74f3fe6f /src | |
parent | c70d4ffb6f1378b12eb4271bd8737c2931f12286 (diff) | |
download | scintilla-mirror-7b098a59967555b13d083970731c55ca13c87491.tar.gz |
Now handles both case insensitive and case sensitive searching.
Diffstat (limited to 'src')
-rw-r--r-- | src/AutoComplete.cxx | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index 676a4124d..ce151aff7 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -7,9 +7,11 @@ #include <stdlib.h> #include <string.h> +#include <stdio.h> #include "Platform.h" +#include "PropSet.h" #include "AutoComplete.h" AutoComplete::AutoComplete() : @@ -88,7 +90,7 @@ void AutoComplete::SetList(const char *list) { } delete []words; } - lb.Sort(); + //lb.Sort(); } void AutoComplete::Show() { @@ -116,11 +118,42 @@ void AutoComplete::Move(int delta) { } void AutoComplete::Select(const char *word) { - int pos = lb.Find(word); - //Platform::DebugPrintf("Autocompleting at <%s> %d\n", wordCurrent, pos); - if (pos == -1 && autoHide) + int lenWord = strlen(word); + int location = -1; + const int maxItemLen=1000; + char item[maxItemLen]; + int start = 0; // lower bound of the api array block to search + int end = lb.Length() - 1; // upper bound of the api array block to search + while ((start <= end) && (location == -1)) { // Binary searching loop + int pivot = (start + end) / 2; + lb.GetValue(pivot, item, maxItemLen); + int cond = 0; + if (ignoreCase) + cond = CompareNCaseInsensitive(word, item, lenWord); + else + cond = strncmp(word, item, lenWord); + if (!cond) { + // Find first match + while (pivot > start) { + lb.GetValue(pivot-1, item, maxItemLen); + if (ignoreCase) + cond = CompareNCaseInsensitive(word, item, lenWord); + else + cond = strncmp(word, item, lenWord); + if (0 != cond) + break; + --pivot; + } + location = pivot; + } else if (cond < 0) { + end = pivot - 1; + } else if (cond > 0) { + start = pivot + 1; + } + } + if (location == -1 && autoHide) Cancel(); else - lb.Select(pos); + lb.Select(location); } |