diff options
-rw-r--r-- | doc/ScintillaDoc.html | 120 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 5 | ||||
-rw-r--r-- | include/Scintilla.h | 12 | ||||
-rw-r--r-- | include/Scintilla.iface | 12 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 18 | ||||
-rw-r--r-- | src/ScintillaBase.h | 2 |
6 files changed, 151 insertions, 18 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index ed0429efc..9cf880d0e 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -4325,8 +4325,10 @@ struct Sci_TextToFind { <p>When the user makes a selection from the list the container is sent a <code><a class="message" href="#SCN_AUTOCSELECTION">SCN_AUTOCSELECTION</a></code> <a class="jump" href="#Notifications">notification message</a>. On return from the notification Scintilla will insert - the selected text unless the autocompletion list has been cancelled, for example by the container sending - <code><a class="message" href="#SCI_AUTOCCANCEL">SCI_AUTOCCANCEL</a></code>.</p> + the selected text and the container is sent a <code><a class="message" + href="#SCN_AUTOCCOMPLETED">SCN_AUTOCCOMPLETED</a></code> <a class="jump" + href="#Notifications">notification message</a> unless the autocompletion list has been cancelled, for example by the container sending + <code><a class="message" href="#SCI_AUTOCCANCEL">SCI_AUTOCCANCEL</a></code>. </p> <p>To make use of autocompletion you must monitor each character added to the document. See <code>SciTEBase::CharAdded()</code> in SciTEBase.cxx for an example of autocompletion.</p> @@ -4555,10 +4557,10 @@ struct Sci_TextToFind { <p>o The <code><a class="message" href="#SCI_AUTOCSETCHOOSESINGLE">SCI_AUTOCSETCHOOSESINGLE</a></code> message has no effect.<br /> - o When the user makes a selection you are sent a <code><a class="message" + o When the user makes a selection you are sent a <code><a class="jump" href="#SCN_USERLISTSELECTION">SCN_USERLISTSELECTION</a></code> <a class="jump" - href="#Notifications">notification message</a> rather than <code><a class="message" - href="#SCN_AUTOCSELECTION">SCN_AUTOCSELECTION</a></code>.</p> + href="#Notifications">notification message</a> rather than <code><a class="jump" + href="#SCN_AUTOCSELECTION">SCN_AUTOCSELECTION</a></code>.<br> <p>BEWARE: if you have set fillup characters or stop characters, these will still be active with the user list, and may result in items being selected or the user list cancelled due to @@ -6649,7 +6651,9 @@ struct SCNotification { /* SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */ - int ch; /* SCN_CHARADDED, SCN_KEY */ + int ch; + /* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETE, SCN_AUTOCSELECTION, */ + /* SCN_USERLISTSELECTION */ int modifiers; /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */ /* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ @@ -6673,6 +6677,9 @@ struct SCNotification { int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */ int annotationLinesAdded; /* SCN_MODIFIED with SC_MOD_CHANGEANNOTATION */ int updated; /* SCN_UPDATEUI */ + int listCompletionMethod; + /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION */ + }; </pre> @@ -6707,6 +6714,7 @@ struct SCNotification { <a class="message" href="#SCN_AUTOCCHARDELETED">SCN_AUTOCCHARDELETED</a><br /> <a class="message" href="#SCN_FOCUSIN">SCN_FOCUSIN</a><br /> <a class="message" href="#SCN_FOCUSOUT">SCN_FOCUSOUT</a><br /> + <a class="message" href="#SCN_AUTOCCOMPLETED">SCN_AUTOCCOMPLETED</a><br /> </code> <p>The following <code>SCI_*</code> messages are associated with these notifications:</p> @@ -7359,11 +7367,24 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next <td align="left">The position the list was displayed at.</td> </tr> + <tr> + <td align="left"><code>ch</code></td> + + <td align="left">If a fillup character was the method of selection, the used + character, otherwise 0.</td> + </tr> + <tr> + <td align="left"><code>listCompletionMethod</code></td> + + <td align="left">A value indicating the way in which the completion + occurred. See the table below.</td> + </tr> </tbody> </table> <br /> - - + + See the <code><a class="jump" href="#SCN_AUTOCCOMPLETED">SCN_AUTOCCOMPLETED</a></code> notification + for the possible values for <code>listCompletionMethod.</code> <p><b id="SCN_URIDROPPED">SCN_URIDROPPED</b><br /> Only on the GTK+ version. Indicates that the user has dragged a URI such as a file name or Web address onto Scintilla. The container could interpret this as a request to open the file. The @@ -7474,6 +7495,82 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next <td align="left">The text of the selection.</td> </tr> + <tr> + <td align="left"><code>ch</code></td> + + <td align="left">If a fillup character was the method of selection, the used + character, otherwise 0.</td> + </tr> + <tr> + <td align="left"><code>listCompletionMethod</code></td> + + <td align="left">A value indicating the way in which the completion + occurred. See the table below.</td> + </tr> + </tbody> + </table> + <br /> + <table cellpadding="1" cellspacing="2" border="0" summary="Modify notification type flags"> + <tbody> + <tr> + <th align="left">Symbol</th> + + <th>Value</th> + + <th align="left">Meaning</th> + + </tr> + </tbody> + + <tbody valign="top"> + <tr> + <td align="left"><code>SC_AC_FILLUP</code></td> + + <td align="center">0x01</td> + + <td>A fillup character triggered the completion. The character used is + in ch. </td> + + </tr> + + <tr> + <td align="left"><code>SC_AC_DOUBLECLICK</code></td> + + <td align="center">0x02</td> + + <td>A double-click triggered the completion. ch is 0.</td> + + </tr> + + <tr> + <td align="left"><code>SC_AC_TAB</code></td> + + <td align="center">0x04</td> + + <td>The tab key or SCI_TAB triggered the completion. ch is 0.</td> + + </tr> + + <tr> + <td align="left"><code>SC_AC_NEWLINE</code></td> + + <td align="center">0x08</td> + + <td>A new line or SCI_NEWLINE triggered the completion. ch is 0.</td> + + </tr> + + <tr> + <td align="left"><code>SC_AC_COMMAND</code></td> + + <td align="center">0x10</td> + + <td>The + <code> + <a class="message" href="#SCI_AUTOCSELECT">SCI_AUTOCSELECT</a></code> message + triggered the completion. ch is 0.</td> + + </tr> </tbody> </table> @@ -7490,6 +7587,13 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next <code>SCN_FOCUSIN</code> (2028) is fired when Scintilla receives focus and <code>SCN_FOCUSOUT</code> (2029) when it loses focus.</p> + <p><b id="SCN_AUTOCCOMPLETED">SCN_AUTOCCOMPLETED<br /> + </b>This notification is generated after an autocompletion has inserted its + text. The fields are identical to the + <code> + <a class="jump" href="#SCN_AUTOCSELECTION">SCN_AUTOCSELECTION</a></code> + notification.</p> + <h2 id="Images">Images</h2> <p>Two formats are supported for images used in margin markers and autocompletion lists, RGBA and XPM.</p> diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index f2e9528eb..8cb8a61b5 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -472,6 +472,7 @@ <td>Stefan Küng</td> </tr><tr> <td>Jiří Techet</td> + <td>Jonathan Hunt</td> </tr> </table> <p> @@ -498,6 +499,10 @@ This change in behaviours is conditional on setting the SCI_SETADDITIONALSELECTIONTYPING property. </li> <li> + Autocompletion lists send an SCN_AUTOCCOMPLETED notification after the text has been inserted. + <a href="http://sourceforge.net/p/scintilla/feature-requests/1109/">Feature #1109.</a> + </li> + <li> The case mode style attribute can now be SC_CASE_CAMEL. </li> <li> diff --git a/include/Scintilla.h b/include/Scintilla.h index 7244bded8..bc2b5080d 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -1024,6 +1024,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCMOD_ALT 4 #define SCMOD_SUPER 8 #define SCMOD_META 16 +#define SC_AC_FILLUP 1 +#define SC_AC_DOUBLECLICK 2 +#define SC_AC_TAB 3 +#define SC_AC_NEWLINE 4 +#define SC_AC_COMMAND 5 #define SCN_STYLENEEDED 2000 #define SCN_CHARADDED 2001 #define SCN_SAVEPOINTREACHED 2002 @@ -1053,6 +1058,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCN_HOTSPOTRELEASECLICK 2027 #define SCN_FOCUSIN 2028 #define SCN_FOCUSOUT 2029 +#define SCN_AUTOCCOMPLETED 2030 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */ /* These structures are defined to be exactly the same shape as the Win32 @@ -1125,7 +1131,9 @@ struct SCNotification { /* SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */ - int ch; /* SCN_CHARADDED, SCN_KEY */ + int ch; + /* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETED, SCN_AUTOCSELECTION, */ + /* SCN_USERLISTSELECTION */ int modifiers; /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */ /* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ @@ -1149,6 +1157,8 @@ struct SCNotification { int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */ int annotationLinesAdded; /* SCN_MODIFIED with SC_MOD_CHANGEANNOTATION */ int updated; /* SCN_UPDATEUI */ + int listCompletionMethod; + /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION, */ }; #if defined(__cplusplus) && defined(SCI_NAMESPACE) diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 818a2ca38..69331157f 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2657,6 +2657,13 @@ val SCMOD_ALT=4 val SCMOD_SUPER=8 val SCMOD_META=16 +enu CompletionMethods=SC_AC_ +val SC_AC_FILLUP=1 +val SC_AC_DOUBLECLICK=2 +val SC_AC_TAB=3 +val SC_AC_NEWLINE=4 +val SC_AC_COMMAND=5 + ################################################ # For SciLexer.h enu Lexer=SCLEX_ @@ -4648,7 +4655,7 @@ evt void MacroRecord=2009(int message, int wParam, int lParam) evt void MarginClick=2010(int modifiers, int position, int margin) evt void NeedShown=2011(int position, int length) evt void Painted=2013(void) -evt void UserListSelection=2014(int listType, string text, int position) +evt void UserListSelection=2014(int listType, string text, int positionint, int ch, CompletionMethods listCompletionMethod) evt void URIDropped=2015(string text) evt void DwellStart=2016(int position, int x, int y) evt void DwellEnd=2017(int position, int x, int y) @@ -4656,7 +4663,7 @@ evt void Zoom=2018(void) evt void HotSpotClick=2019(int modifiers, int position) evt void HotSpotDoubleClick=2020(int modifiers, int position) evt void CallTipClick=2021(int position) -evt void AutoCSelection=2022(string text, int position) +evt void AutoCSelection=2022(string text, int position, int ch, CompletionMethods listCompletionMethod) evt void IndicatorClick=2023(int modifiers, int position) evt void IndicatorRelease=2024(int modifiers, int position) evt void AutoCCancelled=2025(void) @@ -4664,6 +4671,7 @@ evt void AutoCCharDeleted=2026(void) evt void HotSpotReleaseClick=2027(int modifiers, int position) evt void FocusIn=2028(void) evt void FocusOut=2029(void) +evt void AutoCCompleted=2030(string text, int position, int ch, CompletionMethods listCompletionMethod) # There are no provisional features currently diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index b52fb9a04..3d908d026 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -168,10 +168,10 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) { EnsureCaretVisible(); return 0; case SCI_TAB: - AutoCompleteCompleted(); + AutoCompleteCompleted(0, SC_AC_TAB); return 0; case SCI_NEWLINE: - AutoCompleteCompleted(); + AutoCompleteCompleted(0, SC_AC_NEWLINE); return 0; default: @@ -202,7 +202,7 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) { void ScintillaBase::AutoCompleteDoubleClick(void *p) { ScintillaBase *sci = reinterpret_cast<ScintillaBase *>(p); - sci->AutoCompleteCompleted(); + sci->AutoCompleteCompleted(0, SC_AC_DOUBLECLICK); } void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) { @@ -340,7 +340,7 @@ void ScintillaBase::AutoCompleteMoveToCurrentWord() { void ScintillaBase::AutoCompleteCharacterAdded(char ch) { if (ac.IsFillUpChar(ch)) { - AutoCompleteCompleted(); + AutoCompleteCompleted(ch, SC_AC_FILLUP); } else if (ac.IsStopChar(ch)) { AutoCompleteCancel(); } else { @@ -363,7 +363,7 @@ void ScintillaBase::AutoCompleteCharacterDeleted() { NotifyParent(scn); } -void ScintillaBase::AutoCompleteCompleted() { +void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod) { int item = ac.GetSelection(); if (item == -1) { AutoCompleteCancel(); @@ -376,6 +376,8 @@ void ScintillaBase::AutoCompleteCompleted() { SCNotification scn = {}; scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION; scn.message = 0; + scn.ch = ch; + scn.listCompletionMethod = completionMethod; scn.wParam = listType; scn.listType = listType; Position firstPos = ac.posStart - ac.startLen; @@ -398,6 +400,10 @@ void ScintillaBase::AutoCompleteCompleted() { return; AutoCompleteInsert(firstPos, endPos - firstPos, selected.c_str(), static_cast<int>(selected.length())); SetLastXChosen(); + + scn.nmhdr.code = SCN_AUTOCCOMPLETED; + NotifyParent(scn); + } int ScintillaBase::AutoCompleteGetCurrent() const { @@ -788,7 +794,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.posStart; case SCI_AUTOCCOMPLETE: - AutoCompleteCompleted(); + AutoCompleteCompleted(0, SC_AC_COMMAND); break; case SCI_AUTOCSETSEPARATOR: diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index d6401cc30..4bdf24ef2 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -75,7 +75,7 @@ protected: int AutoCompleteGetCurrentText(char *buffer) const; void AutoCompleteCharacterAdded(char ch); void AutoCompleteCharacterDeleted(); - void AutoCompleteCompleted(); + void AutoCompleteCompleted(char ch, unsigned int completionMethod); void AutoCompleteMoveToCurrentWord(); static void AutoCompleteDoubleClick(void *p); |