diff options
author | nyamatongwe <unknown> | 2009-10-18 21:05:35 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2009-10-18 21:05:35 +0000 |
commit | 9edc5aea8c33e2f11de7597b21154bd572baee35 (patch) | |
tree | f618ccb2c153b6f02f736dabd87ce918791f7b44 | |
parent | 67575dc496a55f7abda537d64eca4542d9528bb9 (diff) | |
download | scintilla-mirror-9edc5aea8c33e2f11de7597b21154bd572baee35.tar.gz |
AutoCGetCurrentText added by Nick Treleaven.
-rw-r--r-- | doc/ScintillaDoc.html | 16 | ||||
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 4 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 20 | ||||
-rw-r--r-- | src/ScintillaBase.h | 1 |
5 files changed, 40 insertions, 2 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 47b2bb501..05149c9b5 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -3703,6 +3703,8 @@ struct TextToFind { <a class="message" href="#SCI_AUTOCSELECT">SCI_AUTOCSELECT(<unused>, const char *select)</a><br /> <a class="message" href="#SCI_AUTOCGETCURRENT">SCI_AUTOCGETCURRENT</a><br /> + <a class="message" href="#SCI_AUTOCGETCURRENTTEXT">SCI_AUTOCGETCURRENTTEXT(<unused>, + char *text)</a><br /> <a class="message" href="#SCI_AUTOCSETCANCELATSTART">SCI_AUTOCSETCANCELATSTART(bool cancel)</a><br /> <a class="message" href="#SCI_AUTOCGETCANCELATSTART">SCI_AUTOCGETCANCELATSTART</a><br /> @@ -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 <a class="message" href="#SCI_AUTOCSETAUTOHIDE"><code>SCI_AUTOCSETAUTOHIDE</code></a>).<br /> - The current selection can be retrieved with <code>SCI_AUTOCGETCURRENT</code> - </p> + The current selection index can be retrieved with <code>SCI_AUTOCGETCURRENT</code>.</p> + + <p><b id="SCI_AUTOCGETCURRENTTEXT">SCI_AUTOCGETCURRENTTEXT(<unused>, char *text)</b><br /> + This message retrieves the current selected text in the autocompletion list. Normally the + <a class="message" href="#SCN_AUTOCSELECTION"><code>SCN_AUTOCSELECTION</code></a> notification + is used instead.</p> + + <p></p>The value is copied to the <code>text</code> buffer, returning the length (not including the + terminating 0). If not found, an empty string is copied to the buffer and 0 is returned.</p> + + <p>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.</p> <p><b id="SCI_AUTOCSETCANCELATSTART">SCI_AUTOCSETCANCELATSTART(bool cancel)</b><br /> <b id="SCI_AUTOCGETCANCELATSTART">SCI_AUTOCGETCANCELATSTART</b><br /> 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<char *>(lParam)); + case SCI_AUTOCSETCANCELATSTART: ac.cancelAtStartPos = wParam != 0; break; diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index 15b514c2b..73fcd72b5 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -72,6 +72,7 @@ protected: void AutoCompleteCancel(); void AutoCompleteMove(int delta); int AutoCompleteGetCurrent(); + int AutoCompleteGetCurrentText(char *buffer); void AutoCompleteCharacterAdded(char ch); void AutoCompleteCharacterDeleted(); void AutoCompleteCompleted(); |