aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2014-05-24 10:20:06 +1000
committerNeil <nyamatongwe@gmail.com>2014-05-24 10:20:06 +1000
commitc4fb5a967fa550def8a75f12f6216b56aa68a179 (patch)
tree7269a7d3042559cf6556a6da753a95adb4be2665
parent4270f2252efd78f6711e25e36c6d22556c90177a (diff)
downloadscintilla-mirror-c4fb5a967fa550def8a75f12f6216b56aa68a179.tar.gz
SCI_AUTOCSETMULTI allows setting whether autocompletion text is inserted at each
selection when multiple selections are active. From Mitchell Foral.
-rw-r--r--doc/ScintillaDoc.html10
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--include/Scintilla.h4
-rw-r--r--include/Scintilla.iface10
-rw-r--r--src/ScintillaBase.cxx34
-rw-r--r--src/ScintillaBase.h1
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 @@
<h1>Scintilla Documentation</h1>
- <p>Last edited 1 May 2014 NH</p>
+ <p>Last edited 24 May 2014 NH</p>
<p>There is <a class="jump" href="Design.html">an overview of the internal design of
Scintilla</a>.<br />
@@ -4160,6 +4160,8 @@ struct Sci_TextToFind {
<a class="message" href="#SCI_AUTOCGETIGNORECASE">SCI_AUTOCGETIGNORECASE</a><br />
<a class="message" href="#SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR">SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR(int behaviour)</a><br />
<a class="message" href="#SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR">SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR</a><br />
+ <a class="message" href="#SCI_AUTOCSETMULTI">SCI_AUTOCSETMULTI(int multi)</a><br />
+ <a class="message" href="#SCI_AUTOCGETMULTI">SCI_AUTOCGETMULTI</a><br />
<a class="message" href="#SCI_AUTOCSETORDER">SCI_AUTOCSETORDER(int order)</a><br />
<a class="message" href="#SCI_AUTOCGETORDER">SCI_AUTOCGETORDER</a><br />
<a class="message" href="#SCI_AUTOCSETAUTOHIDE">SCI_AUTOCSETAUTOHIDE(bool autoHide)</a><br />
@@ -4277,6 +4279,12 @@ struct Sci_TextToFind {
This corresponds to a behaviour property of <code>SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE</code> (0).
If you want autocompletion to ignore case at all, choose <code>SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE</code> (1).</p>
+ <p><b id="SCI_AUTOCSETMULTI">SCI_AUTOCSETMULTI(int multi)</b><br />
+ <b id="SCI_AUTOCGETMULTI">SCI_AUTOCGETMULTI</b><br />
+ When autocompleting with multiple selections present, the autocompleted text can go into just the main selection with
+ <code>SC_MULTIAUTOC_ONCE</code> (0) or into each selection with <code>SC_MULTIAUTOC_EACH</code> (1).
+ The default is <code>SC_MULTIAUTOC_ONCE</code>.</p>
+
<p><b id="SCI_AUTOCSETORDER">SCI_AUTOCSETORDER(int order)</b><br />
<b id="SCI_AUTOCGETORDER">SCI_AUTOCGETORDER</b><br />
The default setting <code>SC_ORDER_PRESORTED</code> (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.
</li>
<li>
+ When multiple selections are active, autocompletion text may be inserted at each selection with new
+ SCI_AUTOCSETMULTI method.
+ </li>
+ <li>
C++ lexer fixes raw string recognition so that R"xxx(blah)xxx" is styled as SCE_C_STRINGRAW.
</li>
</ul>
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<sel.Count(); r++) {
+ if (!RangeContainsProtected(sel.Range(r).Start().Position(),
+ sel.Range(r).End().Position())) {
+ int positionInsert = sel.Range(r).Start().Position();
+ positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
+ if (positionInsert - removeLen >= 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<int>(wParam);
+ break;
+
+ case SCI_AUTOCGETMULTI:
+ return multiAutoCMode;
+
case SCI_AUTOCSETORDER:
ac.autoSort = static_cast<int>(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();