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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
# HG changeset patch
# User Neil <nyamatongwe@gmail.com>
# Date 1491012984 -39600
# Node ID 47fa874827a53ca2595aab2df1efa17834f24e06
# Parent 35d652a3344bede120f1c59d9dc0b453a11c736b
More encapsulation for Decoration and DecorationList.
diff -r 35d652a3344b -r 47fa874827a5 src/Decoration.cxx
--- a/src/Decoration.cxx Sat Apr 01 10:43:59 2017 +1100
+++ b/src/Decoration.cxx Sat Apr 01 13:16:24 2017 +1100
@@ -26,7 +26,7 @@
using namespace Scintilla;
#endif
-Decoration::Decoration(int indicator_) : next(0), indicator(indicator_) {
+Decoration::Decoration(int indicator_) : indicator(indicator_), next(0) {
}
Decoration::~Decoration() {
@@ -43,7 +43,7 @@
DecorationList::~DecorationList() {
Decoration *deco = root;
while (deco) {
- Decoration *decoNext = deco->next;
+ Decoration *decoNext = deco->Next();
delete deco;
deco = decoNext;
}
@@ -52,8 +52,8 @@
}
Decoration *DecorationList::DecorationFromIndicator(int indicator) {
- for (Decoration *deco=root; deco; deco = deco->next) {
- if (deco->indicator == indicator) {
+ for (Decoration *deco=root; deco; deco = deco->Next()) {
+ if (deco->Indicator() == indicator) {
return deco;
}
}
@@ -68,9 +68,9 @@
Decoration *decoPrev = 0;
Decoration *deco = root;
- while (deco && (deco->indicator < indicator)) {
+ while (deco && (deco->Indicator() < indicator)) {
decoPrev = deco;
- deco = deco->next;
+ deco = deco->Next();
}
if (decoPrev == 0) {
decoNew->next = root;
@@ -85,17 +85,17 @@
void DecorationList::Delete(int indicator) {
Decoration *decoToDelete = 0;
if (root) {
- if (root->indicator == indicator) {
+ if (root->Indicator() == indicator) {
decoToDelete = root;
- root = root->next;
+ root = root->Next();
} else {
Decoration *deco=root;
- while (deco->next && !decoToDelete) {
- if (deco->next && deco->next->indicator == indicator) {
- decoToDelete = deco->next;
- deco->next = decoToDelete->next;
+ while (deco->Next() && !decoToDelete) {
+ if (deco->Next() && deco->Next()->Indicator() == indicator) {
+ decoToDelete = deco->Next();
+ deco->next = decoToDelete->Next();
} else {
- deco = deco->next;
+ deco = deco->Next();
}
}
}
@@ -133,7 +133,7 @@
void DecorationList::InsertSpace(int position, int insertLength) {
const bool atEnd = position == lengthDocument;
lengthDocument += insertLength;
- for (Decoration *deco=root; deco; deco = deco->next) {
+ for (Decoration *deco=root; deco; deco = deco->Next()) {
deco->rs.InsertSpace(position, insertLength);
if (atEnd) {
deco->rs.FillRange(position, 0, insertLength);
@@ -144,7 +144,7 @@
void DecorationList::DeleteRange(int position, int deleteLength) {
lengthDocument -= deleteLength;
Decoration *deco;
- for (deco=root; deco; deco = deco->next) {
+ for (deco=root; deco; deco = deco->Next()) {
deco->rs.DeleteRange(position, deleteLength);
}
DeleteAnyEmpty();
@@ -154,20 +154,20 @@
Decoration *deco = root;
while (deco) {
if ((lengthDocument == 0) || deco->Empty()) {
- Delete(deco->indicator);
+ Delete(deco->Indicator());
deco = root;
} else {
- deco = deco->next;
+ deco = deco->Next();
}
}
}
int DecorationList::AllOnFor(int position) const {
int mask = 0;
- for (Decoration *deco=root; deco; deco = deco->next) {
+ for (Decoration *deco=root; deco; deco = deco->Next()) {
if (deco->rs.ValueAt(position)) {
- if (deco->indicator < INDIC_IME) {
- mask |= 1 << deco->indicator;
+ if (deco->Indicator() < INDIC_IME) {
+ mask |= 1 << deco->Indicator();
}
}
}
diff -r 35d652a3344b -r 47fa874827a5 src/Decoration.h
--- a/src/Decoration.h Sat Apr 01 10:43:59 2017 +1100
+++ b/src/Decoration.h Sat Apr 01 13:16:24 2017 +1100
@@ -12,15 +12,21 @@
#endif
class Decoration {
+ int indicator;
public:
Decoration *next;
RunStyles rs;
- int indicator;
explicit Decoration(int indicator_);
~Decoration();
bool Empty() const;
+ Decoration *Next() const {
+ return next;
+ }
+ int Indicator() const {
+ return indicator;
+ }
};
class DecorationList {
@@ -32,13 +38,17 @@
Decoration *Create(int indicator, int length);
void Delete(int indicator);
void DeleteAnyEmpty();
-public:
Decoration *root;
bool clickNotified;
+public:
DecorationList();
~DecorationList();
+ Decoration *Root() const {
+ return root;
+ }
+
void SetCurrentIndicator(int indicator);
int GetCurrentIndicator() const { return currentIndicator; }
@@ -55,6 +65,13 @@
int ValueAt(int indicator, int position);
int Start(int indicator, int position);
int End(int indicator, int position);
+
+ virtual bool ClickNotified() const {
+ return clickNotified;
+ }
+ virtual void SetClickNotified(bool notified) {
+ clickNotified = notified;
+ }
};
#ifdef SCI_NAMESPACE
diff -r 35d652a3344b -r 47fa874827a5 src/EditView.cxx
--- a/src/EditView.cxx Sat Apr 01 10:43:59 2017 +1100
+++ b/src/EditView.cxx Sat Apr 01 13:16:24 2017 +1100
@@ -1015,8 +1015,8 @@
const Sci::Position lineStart = ll->LineStart(subLine);
const Sci::Position posLineEnd = posLineStart + lineEnd;
- for (Decoration *deco = model.pdoc->decorations.root; deco; deco = deco->next) {
- if (under == vsDraw.indicators[deco->indicator].under) {
+ for (Decoration *deco = model.pdoc->decorations.Root(); deco; deco = deco->Next()) {
+ if (under == vsDraw.indicators[deco->Indicator()].under) {
Sci::Position startPos = posLineStart + lineStart;
if (!deco->rs.ValueAt(startPos)) {
startPos = deco->rs.EndRun(startPos);
@@ -1024,12 +1024,12 @@
while ((startPos < posLineEnd) && (deco->rs.ValueAt(startPos))) {
const Range rangeRun(deco->rs.StartRun(startPos), deco->rs.EndRun(startPos));
const Sci::Position endPos = std::min(rangeRun.end, posLineEnd);
- const bool hover = vsDraw.indicators[deco->indicator].IsDynamic() &&
+ const bool hover = vsDraw.indicators[deco->Indicator()].IsDynamic() &&
rangeRun.ContainsCharacter(hoverIndicatorPos);
const int value = deco->rs.ValueAt(startPos);
Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal;
const Sci::Position posSecond = model.pdoc->MovePositionOutsideChar(rangeRun.First() + 1, 1);
- DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart,
+ DrawIndicator(deco->Indicator(), startPos - posLineStart, endPos - posLineStart,
surface, vsDraw, ll, xStart, rcLine, posSecond - posLineStart, subLine, drawState, value);
startPos = endPos;
if (!deco->rs.ValueAt(startPos)) {
@@ -1619,10 +1619,10 @@
}
if (vsDraw.indicatorsSetFore > 0) {
// At least one indicator sets the text colour so see if it applies to this segment
- for (Decoration *deco = model.pdoc->decorations.root; deco; deco = deco->next) {
+ for (Decoration *deco = model.pdoc->decorations.Root(); deco; deco = deco->Next()) {
const int indicatorValue = deco->rs.ValueAt(ts.start + posLineStart);
if (indicatorValue) {
- const Indicator &indicator = vsDraw.indicators[deco->indicator];
+ const Indicator &indicator = vsDraw.indicators[deco->Indicator()];
const bool hover = indicator.IsDynamic() &&
((model.hoverIndicatorPos >= ts.start + posLineStart) &&
(model.hoverIndicatorPos <= ts.end() + posLineStart));
diff -r 35d652a3344b -r 47fa874827a5 src/Editor.cxx
--- a/src/Editor.cxx Sat Apr 01 10:43:59 2017 +1100
+++ b/src/Editor.cxx Sat Apr 01 13:16:24 2017 +1100
@@ -2097,12 +2097,12 @@
}
void Editor::ClearDocumentStyle() {
- Decoration *deco = pdoc->decorations.root;
+ Decoration *deco = pdoc->decorations.Root();
while (deco) {
// Save next in case deco deleted
- Decoration *decoNext = deco->next;
- if (deco->indicator < INDIC_CONTAINER) {
- pdoc->DecorationSetCurrentIndicator(deco->indicator);
+ Decoration *decoNext = deco->Next();
+ if (deco->Indicator() < INDIC_CONTAINER) {
+ pdoc->DecorationSetCurrentIndicator(deco->Indicator());
pdoc->DecorationFillRange(0, 0, pdoc->Length());
}
deco = decoNext;
@@ -2407,9 +2407,9 @@
void Editor::NotifyIndicatorClick(bool click, Sci::Position position, int modifiers) {
int mask = pdoc->decorations.AllOnFor(position);
- if ((click && mask) || pdoc->decorations.clickNotified) {
+ if ((click && mask) || pdoc->decorations.ClickNotified()) {
SCNotification scn = {};
- pdoc->decorations.clickNotified = click;
+ pdoc->decorations.SetClickNotified(click);
scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE;
scn.modifiers = modifiers;
scn.position = position;
@@ -4622,9 +4622,9 @@
if (vs.indicatorsDynamic == 0)
return;
if (position != INVALID_POSITION) {
- for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
- if (vs.indicators[deco->indicator].IsDynamic()) {
- if (pdoc->decorations.ValueAt(deco->indicator, position)) {
+ for (Decoration *deco = pdoc->decorations.Root(); deco; deco = deco->Next()) {
+ if (vs.indicators[deco->Indicator()].IsDynamic()) {
+ if (pdoc->decorations.ValueAt(deco->Indicator(), position)) {
hoverIndicatorPos = position;
}
}
diff -r 35d652a3344b -r 47fa874827a5 src/PositionCache.cxx
--- a/src/PositionCache.cxx Sat Apr 01 10:43:59 2017 +1100
+++ b/src/PositionCache.cxx Sat Apr 01 13:16:24 2017 +1100
@@ -483,8 +483,8 @@
}
}
if (pvsDraw && pvsDraw->indicatorsSetFore > 0) {
- for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
- if (pvsDraw->indicators[deco->indicator].OverridesTextFore()) {
+ for (Decoration *deco = pdoc->decorations.Root(); deco; deco = deco->Next()) {
+ if (pvsDraw->indicators[deco->Indicator()].OverridesTextFore()) {
Sci::Position startPos = deco->rs.EndRun(posLineStart);
while (startPos < (posLineStart + lineRange.end)) {
Insert(startPos - posLineStart);
|