From 0d2bd5e004b657be9bd66e26161f1cf7299707ea Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 17 Jun 2012 13:38:21 +1000 Subject: Use std::string instead of fixed size strings. Decrease direct access to the autocompletion list box from outside AutoComplete. --- src/AutoComplete.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/AutoComplete.cxx') diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index aa65810eb..82773f4db 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -10,6 +10,8 @@ #include #include +#include + #include "Platform.h" #include "CharacterSet.h" @@ -101,6 +103,16 @@ void AutoComplete::SetList(const char *list) { lb->SetList(list, separator, typesep); } +int AutoComplete::GetSelection() const { + return lb->GetSelection(); +} + +std::string AutoComplete::GetValue(int item) const { + char value[maxItemLen]; + lb->GetValue(item, value, sizeof(value)); + return std::string(value); +} + void AutoComplete::Show(bool show) { lb->Show(show); if (show) @@ -130,7 +142,6 @@ void AutoComplete::Move(int delta) { void AutoComplete::Select(const char *word) { size_t lenWord = strlen(word); int location = -1; - const int maxItemLen=1000; 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 -- cgit v1.2.3