From bd0b16f697913cc48beb8553aa1e666e94bd4454 Mon Sep 17 00:00:00 2001
From: nyamatongwe
+
@@ -3782,8 +3784,18 @@ struct TextToFind {
item is found, it is selected. If the item is not found, the autocompletion list closes if
auto-hide is true (see ).
- The current selection can be retrieved with SCI_AUTOCGETCURRENT
-
SCI_AUTOCGETCURRENT.
+
+ SCI_AUTOCGETCURRENTTEXT(<unused>, char *text)
+ This message retrieves the current selected text in the autocompletion list. Normally the
+ notification
+ is used instead.
text buffer, returning the length (not including the
+ terminating 0). If not found, an empty string is copied to the buffer and 0 is returned.
+
+ If the value argument is 0 then the length that should be allocated to store the value is + returned; again, the terminating 0 is not included.
SCI_AUTOCSETCANCELATSTART(bool cancel)
SCI_AUTOCGETCANCELATSTART
diff --git a/include/Scintilla.h b/include/Scintilla.h
index b9871ecb8..e9bba868c 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -652,6 +652,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_SETWHITESPACECHARS 2443
#define SCI_SETCHARSDEFAULT 2444
#define SCI_AUTOCGETCURRENT 2445
+#define SCI_AUTOCGETCURRENTTEXT 2610
#define SCI_ALLOCATE 2446
#define SCI_TARGETASUTF8 2447
#define SCI_SETLENGTHFORENCODE 2448
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index fd89aa3f8..647506cf4 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1724,6 +1724,10 @@ fun void SetCharsDefault=2444(,)
# Get currently selected item position in the auto-completion list
fun int AutoCGetCurrent=2445(,)
+# Get currently selected item text in the auto-completion list
+# Returns the length of the item text
+fun int AutoCGetCurrentText=2610(, stringresult s)
+
# Enlarge the document to a particular size of text bytes.
fun void Allocate=2446(int bytes,)
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 3aba5fb7b..8b6e7a4cb 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -392,6 +392,23 @@ int ScintillaBase::AutoCompleteGetCurrent() {
return ac.lb->GetSelection();
}
+int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) {
+ if (ac.Active()) {
+ int item = ac.lb->GetSelection();
+ char selected[1000];
+ selected[0] = '\0';
+ if (item != -1) {
+ ac.lb->GetValue(item, selected, sizeof(selected));
+ if (buffer != NULL)
+ strcpy(buffer, selected);
+ return strlen(selected);
+ }
+ }
+ if (buffer != NULL)
+ *buffer = '\0';
+ return 0;
+}
+
void ScintillaBase::CallTipShow(Point pt, const char *defn) {
ac.Cancel();
pt.y += vs.lineHeight;
@@ -564,6 +581,9 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
case SCI_AUTOCGETCURRENT:
return AutoCompleteGetCurrent();
+ case SCI_AUTOCGETCURRENTTEXT:
+ return AutoCompleteGetCurrentText(reinterpret_cast