aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2005-03-09 03:34:46 +0000
committernyamatongwe <unknown>2005-03-09 03:34:46 +0000
commitafc7afe13b6eb49984e1c9c66eef3cebc1392a09 (patch)
tree526577481daf6dbee2aeb0142d9baa8c3b97e117 /src
parentb64920976eb1ddc19630f435c2aee7788b6b6815 (diff)
downloadscintilla-mirror-afc7afe13b6eb49984e1c9c66eef3cebc1392a09.tar.gz
Patch from Blair McGlashan to send a notification before accepting an autocompletion.
Diffstat (limited to 'src')
-rw-r--r--src/AutoComplete.cxx7
-rw-r--r--src/AutoComplete.h2
-rw-r--r--src/ScintillaBase.cxx36
-rw-r--r--src/ScintillaBase.h2
4 files changed, 27 insertions, 20 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index b4d14944f..65b1788bb 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -118,9 +118,10 @@ void AutoComplete::SetList(const char *list) {
}
}
-void AutoComplete::Show() {
- lb->Show();
- lb->Select(0);
+void AutoComplete::Show(bool show) {
+ lb->Show(show);
+ if (show)
+ lb->Select(0);
}
void AutoComplete::Cancel() {
diff --git a/src/AutoComplete.h b/src/AutoComplete.h
index 981fb44c0..ee5a2de4c 100644
--- a/src/AutoComplete.h
+++ b/src/AutoComplete.h
@@ -57,7 +57,7 @@ public:
/// The list string contains a sequence of words separated by the separator character
void SetList(const char *list);
- void Show();
+ void Show(bool show);
void Cancel();
/// Move the current list element by delta, scrolling appropriately
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 78c15f7d7..7735d35db 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -262,7 +262,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
}
rcList.bottom = rcList.top + heightAlloced;
ac.lb->SetPositionRelative(rcList, wMain);
- ac.Show();
+ ac.Show(true);
if (lenEntered != 0) {
AutoCompleteMoveToCurrentWord();
}
@@ -312,25 +312,31 @@ void ScintillaBase::AutoCompleteCompleted() {
selected[0] = '\0';
if (item != -1) {
ac.lb->GetValue(item, selected, sizeof(selected));
+ } else {
+ ac.Cancel();
+ return;
}
- ac.Cancel();
- if (item == -1)
+
+ ac.Show(false);
+
+ listSelected = selected;
+ SCNotification scn;
+ scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION;
+ scn.message = 0;
+ scn.wParam = listType;
+ scn.listType = listType;
+ Position firstPos = ac.posStart - ac.startLen;
+ scn.lParam = firstPos;
+ scn.text = listSelected.c_str();
+ NotifyParent(scn);
+
+ if (!ac.Active())
return;
+ ac.Cancel();
- if (listType > 0) {
- userListSelected = selected;
- SCNotification scn;
- scn.nmhdr.code = SCN_USERLISTSELECTION;
- scn.message = 0;
- scn.wParam = listType;
- scn.listType = listType;
- scn.lParam = 0;
- scn.text = userListSelected.c_str();
- NotifyParent(scn);
+ if (listType > 0)
return;
- }
- Position firstPos = ac.posStart - ac.startLen;
Position endPos = currentPos;
if (ac.dropRestOfWord)
endPos = pdoc->ExtendWordSelect(endPos, 1, true);
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index 6ea23ab5a..362231148 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -37,7 +37,7 @@ protected:
CallTip ct;
int listType; ///< 0 is an autocomplete list
- SString userListSelected; ///< Receives listbox selected string
+ SString listSelected; ///< Receives listbox selected string
#ifdef SCI_LEXER
int lexLanguage;