aboutsummaryrefslogtreecommitdiff
path: root/src/scintilla.patch
blob: 837923daea608eb33ec92152cf334b4c98c92a98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
diff -r 5693714a8b0b src/Catalogue.cxx
--- a/src/Catalogue.cxx	Fri Dec 06 16:19:52 2013 +1100
+++ b/src/Catalogue.cxx	Sun Dec 15 21:21:20 2013 -0500
@@ -74,6 +74,7 @@
 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
 #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer);
 
+#if 0
 //++Autogenerated -- run scripts/LexGen.py to regenerate
 //**\(\tLINK_LEXER(\*);\n\)
 	LINK_LEXER(lmA68k);
@@ -187,6 +188,8 @@
 	LINK_LEXER(lmYAML);
 
 //--Autogenerated -- end of automatically generated section
+#endif
+	LINK_LEXER(lmLPeg);
 
 	return 1;
 }
diff -r a4286bbf7081 include/Scintilla.h
--- a/include/Scintilla.h	Thu May 22 09:18:18 2014 +1000
+++ b/include/Scintilla.h	Sun May 25 17:30:19 2014 -0400
@@ -717,6 +717,10 @@
 #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 -r a4286bbf7081 src/ScintillaBase.cxx
--- a/src/ScintillaBase.cxx	Thu May 22 09:18:18 2014 +1000
+++ b/src/ScintillaBase.cxx	Sun May 25 17:30:19 2014 -0400
@@ -57,6 +57,7 @@
 	displayPopupMenu = true;
 	listType = 0;
 	maxListWidth = 0;
+	multiAutoCMode = SC_MULTIAUTOC_ONCE;
 }
 
 ScintillaBase::~ScintillaBase() {
@@ -197,9 +198,30 @@
 
 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) {
+					positionInsert -= removeLen;
+					pdoc->DeleteChars(positionInsert, 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) {
@@ -819,6 +841,13 @@
 	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 -r a4286bbf7081 src/ScintillaBase.h
--- a/src/ScintillaBase.h	Thu May 22 09:18:18 2014 +1000
+++ b/src/ScintillaBase.h	Sun May 25 17:30:19 2014 -0400
@@ -46,6 +46,7 @@
 
 	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();