From 0e25a153a1970e5b895072f265c02bac9fd7f3fa Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 24 May 2014 10:20:06 +1000 Subject: SCI_AUTOCSETMULTI allows setting whether autocompletion text is inserted at each selection when multiple selections are active. From Mitchell Foral. --- doc/ScintillaDoc.html | 10 +++++++++- doc/ScintillaHistory.html | 4 ++++ include/Scintilla.h | 4 ++++ include/Scintilla.iface | 10 ++++++++++ src/ScintillaBase.cxx | 34 +++++++++++++++++++++++++++++++--- src/ScintillaBase.h | 1 + 6 files changed, 59 insertions(+), 4 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index e0880b071..7187eeb24 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -82,7 +82,7 @@

Scintilla Documentation

-

Last edited 1 May 2014 NH

+

Last edited 24 May 2014 NH

There is an overview of the internal design of Scintilla.
@@ -4160,6 +4160,8 @@ struct Sci_TextToFind { SCI_AUTOCGETIGNORECASE
SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR(int behaviour)
SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR
+ SCI_AUTOCSETMULTI(int multi)
+ SCI_AUTOCGETMULTI
SCI_AUTOCSETORDER(int order)
SCI_AUTOCGETORDER
SCI_AUTOCSETAUTOHIDE(bool autoHide)
@@ -4277,6 +4279,12 @@ struct Sci_TextToFind { This corresponds to a behaviour property of SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE (0). If you want autocompletion to ignore case at all, choose SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE (1).

+

SCI_AUTOCSETMULTI(int multi)
+ SCI_AUTOCGETMULTI
+ When autocompleting with multiple selections present, the autocompleted text can go into just the main selection with + SC_MULTIAUTOC_ONCE (0) or into each selection with SC_MULTIAUTOC_EACH (1). + The default is SC_MULTIAUTOC_ONCE.

+

SCI_AUTOCSETORDER(int order)
SCI_AUTOCGETORDER
The default setting SC_ORDER_PRESORTED (0) requires that the list be provided in alphabetical sorted order. diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index f23191ff2..78cbeaa5d 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -467,6 +467,10 @@ Released 22 May 2014.

  • + When multiple selections are active, autocompletion text may be inserted at each selection with new + SCI_AUTOCSETMULTI method. +
  • +
  • C++ lexer fixes raw string recognition so that R"xxx(blah)xxx" is styled as SCE_C_STRINGRAW.
  • diff --git a/include/Scintilla.h b/include/Scintilla.h index f8744c1c0..9bb0ca905 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -717,6 +717,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE 1 #define SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR 2634 #define SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR 2635 +#define SC_MULTIAUTOC_ONCE 0 +#define SC_MULTIAUTOC_EACH 1 +#define SCI_AUTOCSETMULTI 2636 +#define SCI_AUTOCGETMULTI 2637 #define SC_ORDER_PRESORTED 0 #define SC_ORDER_PERFORMSORT 1 #define SC_ORDER_CUSTOM 2 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index f6b17bca8..3e5f51b9c 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1884,6 +1884,16 @@ set void AutoCSetCaseInsensitiveBehaviour=2634(int behaviour,) # Get auto-completion case insensitive behaviour. get int AutoCGetCaseInsensitiveBehaviour=2635(,) +enu MultiAutoComplete=SC_MULTIAUTOC_ +val SC_MULTIAUTOC_ONCE=0 +val SC_MULTIAUTOC_EACH=1 + +# Change the effect of autocompleting when there are multiple selections. +set void AutoCSetMulti=2636(int multi,) + +# Retrieve the effect of autocompleting when there are multiple selections.. +get int AutoCGetMulti=2637(,) + enu Ordering=SC_ORDER_ val SC_ORDER_PRESORTED=0 val SC_ORDER_PERFORMSORT=1 diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 32ad962e8..e39b5e2a8 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -57,6 +57,7 @@ ScintillaBase::ScintillaBase() { displayPopupMenu = true; listType = 0; maxListWidth = 0; + multiAutoCMode = SC_MULTIAUTOC_ONCE; } ScintillaBase::~ScintillaBase() { @@ -197,9 +198,29 @@ void ScintillaBase::AutoCompleteDoubleClick(void *p) { void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) { UndoGroup ug(pdoc); - pdoc->DeleteChars(startPos, removeLen); - const int lengthInserted = pdoc->InsertString(startPos, text, textLen); - SetEmptySelection(startPos + lengthInserted); + if (multiAutoCMode == SC_MULTIAUTOC_ONCE) { + pdoc->DeleteChars(startPos, removeLen); + const int lengthInserted = pdoc->InsertString(startPos, text, textLen); + SetEmptySelection(startPos + lengthInserted); + } else { + // SC_MULTIAUTOC_EACH + for (size_t r=0; r= 0) { + pdoc->DeleteChars(positionInsert - removeLen, removeLen); + } + const int lengthInserted = pdoc->InsertString(positionInsert, text, textLen); + if (lengthInserted > 0) { + sel.Range(r).caret.SetPosition(positionInsert + lengthInserted); + sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted); + } + sel.Range(r).ClearVirtualSpace(); + } + } + } } void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { @@ -813,6 +834,13 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR: return ac.ignoreCaseBehaviour; + case SCI_AUTOCSETMULTI: + multiAutoCMode = static_cast(wParam); + break; + + case SCI_AUTOCGETMULTI: + return multiAutoCMode; + case SCI_AUTOCSETORDER: ac.autoSort = static_cast(wParam); break; diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index 59ffea41e..8440ebecc 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -46,6 +46,7 @@ protected: int listType; ///< 0 is an autocomplete list int maxListWidth; /// Maximum width of list, in average character widths + int multiAutoCMode; /// Mode for autocompleting when multiple selections are present #ifdef SCI_LEXER LexState *DocumentLexState(); -- cgit v1.2.3