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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
# HG changeset patch
# User Neil <nyamatongwe@gmail.com>
# Date 1488885645 -39600
# Node ID 23546875480b1ee4a3f309c738f64166a0409a46
# Parent 6c62b379a52e1d4a2feda80bcec9b352f120dcb6
Bug [#1910]. Accessibility support may be queried and, on GTK+, disabled.
diff -r 6c62b379a52e -r 23546875480b cocoa/ScintillaCocoa.mm
--- a/cocoa/ScintillaCocoa.mm Tue Mar 07 15:54:33 2017 +1100
+++ b/cocoa/ScintillaCocoa.mm Tue Mar 07 22:20:45 2017 +1100
@@ -906,6 +906,9 @@
return r;
}
+ case SCI_GETACCESSIBILITY:
+ return SC_ACCESSIBILITY_ENABLED;
+
default:
sptr_t r = ScintillaBase::WndProc(iMessage, wParam, lParam);
diff -r 6c62b379a52e -r 23546875480b doc/ScintillaDoc.html
--- a/doc/ScintillaDoc.html Tue Mar 07 15:54:33 2017 +1100
+++ b/doc/ScintillaDoc.html Tue Mar 07 22:20:45 2017 +1100
@@ -367,17 +367,17 @@
<tr>
<td>○ <a class="toc" href="#LongLines">Long lines</a></td>
+ <td>○ <a class="toc" href="#Accessibility">Accessibility</a></td>
+
<td>○ <a class="toc" href="#Lexer">Lexer</a></td>
+ </tr>
+
+ <tr>
<td>○ <a class="toc" href="#LexerObjects">Lexer objects</a></td>
- </tr>
-
- <tr>
<td>○ <a class="toc" href="#Notifications">Notifications</a></td>
- <td>○ <a class="toc" href="#Accessibility">Accessibility</a></td>
-
<td>○ <a class="toc" href="#Images">Images</a></td>
</tr>
@@ -6511,6 +6511,60 @@
of a space character in <code>STYLE_DEFAULT</code>. All the edges can be cleared with
<code>SCI_MULTIEDGECLEARALL</code>.</p>
+ <h2 id="Accessibility">Accessibility</h2>
+
+ <p>Scintilla supports some platform accessibility features.
+ This support differs between platforms.
+ On GTK+ and Cocoa the platform accessibility APIs are implemented sufficiently to
+ make screen readers work.
+ On Win32, the system caret is manipulated to help screen readers.
+ </p>
+
+ <code><a class="message" href="#SCI_SETACCESSIBILITY">SCI_SETACCESSIBILITY(int accessibility)</a><br />
+ <a class="message" href="#SCI_GETACCESSIBILITY">SCI_GETACCESSIBILITY → int</a><br />
+ </code>
+
+ <p><b id="SCI_SETACCESSIBILITY">SCI_SETACCESSIBILITY(int accessibility)</b><br />
+ <b id="SCI_GETACCESSIBILITY">SCI_GETACCESSIBILITY → int</b><br />
+ These messages may enable or disable accessibility and report its current status.</p>
+
+ <p>On most platforms, accessibility is either implemented or not implemented and this can be
+ discovered with <code>SCI_GETACCESSIBILITY</code> with
+ <code>SCI_SETACCESSIBILITY</code> performing no action.
+ On GTK+, there are storage and performance costs to accessibility, so it can be disabled
+ by calling <code>SCI_SETACCESSIBILITY</code>.
+ </p>
+
+ <table class="standard" summary="Accessibility status">
+ <tbody>
+ <tr>
+ <th align="left">Symbol</th>
+
+ <th>Value</th>
+
+ <th align="left">Accessibility status</th>
+ </tr>
+ </tbody>
+
+ <tbody valign="top">
+ <tr>
+ <td align="left"><code>SC_ACCESSIBILITY_DISABLED</code></td>
+
+ <td align="center">0</td>
+
+ <td>Accessibility is disabled.</td>
+ </tr>
+
+ <tr>
+ <td align="left"><code>SC_ACCESSIBILITY_ENABLED</code></td>
+
+ <td align="center">1</td>
+
+ <td>Accessibility is enabled.</td>
+ </tr>
+ </tbody>
+ </table>
+
<h2 id="Lexer">Lexer</h2>
<p>If you define the symbol <code>SCI_LEXER</code> when building Scintilla, (this is sometimes
@@ -7891,15 +7945,6 @@
<a class="jump" href="#SCN_AUTOCSELECTION">SCN_AUTOCSELECTION</a></code>
notification.</p>
- <h2 id="Accessibility">Accessibility</h2>
-
- <p>Scintilla supports some platform accessibility features.
- This support differs between platforms.
- On GTK+ and Cocoa the platform accessibility APIs are implemented sufficiently to
- make screen readers work.
- On Win32, the system caret is manipulated to help screen readers.
- </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 -r 6c62b379a52e -r 23546875480b doc/ScintillaHistory.html
--- a/doc/ScintillaHistory.html Tue Mar 07 15:54:33 2017 +1100
+++ b/doc/ScintillaHistory.html Tue Mar 07 22:20:45 2017 +1100
@@ -527,6 +527,10 @@
Released 19 February 2017.
</li>
<li>
+ Accessibility support may be queried with SCI_GETACCESSIBILITY.
+ On GTK+, accessibility may be disabled by calling SCI_SETACCESSIBILITY.
+ </li>
+ <li>
Lexer added for "indent" language which is styled as plain text but folded by indentation level.
</li>
<li>
diff -r 6c62b379a52e -r 23546875480b gtk/ScintillaGTK.cxx
--- a/gtk/ScintillaGTK.cxx Tue Mar 07 15:54:33 2017 +1100
+++ b/gtk/ScintillaGTK.cxx Tue Mar 07 22:20:45 2017 +1100
@@ -175,6 +175,7 @@
rgnUpdate(0),
repaintFullWindow(false),
styleIdleID(0),
+ accessibilityEnabled(SC_ACCESSIBILITY_ENABLED),
accessible(0) {
sci = sci_;
wMain = GTK_WIDGET(sci);
@@ -875,6 +876,19 @@
return ret;
}
+ case SCI_GETACCESSIBILITY:
+ return accessibilityEnabled;
+
+ case SCI_SETACCESSIBILITY:
+ accessibilityEnabled = wParam;
+ if (accessible) {
+ ScintillaGTKAccessible *sciAccessible = ScintillaGTKAccessible::FromAccessible(accessible);
+ if (sciAccessible) {
+ sciAccessible->SetAccessibility();
+ }
+ }
+ break;
+
default:
return ScintillaBase::WndProc(iMessage, wParam, lParam);
}
diff -r 6c62b379a52e -r 23546875480b gtk/ScintillaGTK.h
--- a/gtk/ScintillaGTK.h Tue Mar 07 15:54:33 2017 +1100
+++ b/gtk/ScintillaGTK.h Tue Mar 07 22:20:45 2017 +1100
@@ -68,6 +68,7 @@
bool repaintFullWindow;
guint styleIdleID;
+ int accessibilityEnabled;
AtkObject *accessible;
// Private so ScintillaGTK objects can not be copied
diff -r 6c62b379a52e -r 23546875480b gtk/ScintillaGTKAccessible.cxx
--- a/gtk/ScintillaGTKAccessible.cxx Tue Mar 07 15:54:33 2017 +1100
+++ b/gtk/ScintillaGTKAccessible.cxx Tue Mar 07 22:20:45 2017 +1100
@@ -788,6 +788,10 @@
//~ iface->set_run_attributes = SetRunAttributes;
}
+bool ScintillaGTKAccessible::Enabled() const {
+ return sci->accessibilityEnabled == SC_ACCESSIBILITY_ENABLED;
+}
+
// Callbacks
void ScintillaGTKAccessible::UpdateCursor() {
@@ -820,6 +824,10 @@
}
void ScintillaGTKAccessible::ChangeDocument(Document *oldDoc, Document *newDoc) {
+ if (!Enabled()) {
+ return;
+ }
+
if (oldDoc == newDoc) {
return;
}
@@ -854,7 +862,15 @@
#endif
}
+void ScintillaGTKAccessible::SetAccessibility() {
+ // Called by ScintillaGTK when application has enabled or disabled accessibility
+ character_offsets.resize(0);
+ character_offsets.push_back(0);
+}
+
void ScintillaGTKAccessible::Notify(GtkWidget *, gint, SCNotification *nt) {
+ if (!Enabled())
+ return;
switch (nt->nmhdr.code) {
case SCN_MODIFIED: {
if (nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
@@ -864,6 +880,13 @@
character_offsets.resize(line + 1);
}
}
+ if (nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
+ // invalidate character offset cache if applicable
+ const Position line = sci->pdoc->LineFromPosition(nt->position);
+ if (character_offsets.size() > static_cast<size_t>(line + 1)) {
+ character_offsets.resize(line + 1);
+ }
+ }
if (nt->modificationType & SC_MOD_INSERTTEXT) {
int startChar = CharacterOffsetFromByteOffset(nt->position);
int lengthChar = sci->pdoc->CountCharacters(nt->position, nt->position + nt->length);
diff -r 6c62b379a52e -r 23546875480b gtk/ScintillaGTKAccessible.h
--- a/gtk/ScintillaGTKAccessible.h Tue Mar 07 15:54:33 2017 +1100
+++ b/gtk/ScintillaGTKAccessible.h Tue Mar 07 22:20:45 2017 +1100
@@ -23,12 +23,16 @@
// cache holding character offset for each line start, see CharacterOffsetFromByteOffset()
std::vector<Position> character_offsets;
+ // cache holding character offset for each line start, see CharacterOffsetFromByteOffset()
+ std::vector<Position> character_offsets;
+
// cached length of the deletion, in characters (see Notify())
int deletionLengthChar;
// local state for comparing
Position old_pos;
std::vector<SelectionRange> old_sels;
+ bool Enabled() const;
void UpdateCursor();
void Notify(GtkWidget *widget, gint code, SCNotification *nt);
static void SciNotify(GtkWidget *widget, gint code, SCNotification *nt, gpointer data) {
@@ -136,6 +140,7 @@
// So ScintillaGTK can notify us
void ChangeDocument(Document *oldDoc, Document *newDoc);
void NotifyReadOnly();
+ void SetAccessibility();
// Helper GtkWidget methods
static AtkObject *WidgetGetAccessibleImpl(GtkWidget *widget, AtkObject **cache, gpointer widget_parent_class);
diff -r 6c62b379a52e -r 23546875480b include/Scintilla.h
--- a/include/Scintilla.h Tue Mar 07 15:54:33 2017 +1100
+++ b/include/Scintilla.h Tue Mar 07 22:20:45 2017 +1100
@@ -593,6 +593,10 @@
#define SCI_LINESSPLIT 2289
#define SCI_SETFOLDMARGINCOLOUR 2290
#define SCI_SETFOLDMARGINHICOLOUR 2291
+#define SC_ACCESSIBILITY_DISABLED 0
+#define SC_ACCESSIBILITY_ENABLED 1
+#define SCI_SETACCESSIBILITY 2702
+#define SCI_GETACCESSIBILITY 2703
#define SCI_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302
diff -r 6c62b379a52e -r 23546875480b include/Scintilla.iface
--- a/include/Scintilla.iface Tue Mar 07 15:54:33 2017 +1100
+++ b/include/Scintilla.iface Tue Mar 07 22:20:45 2017 +1100
@@ -1476,6 +1476,16 @@
# Set the other colour used as a chequerboard pattern in the fold margin
fun void SetFoldMarginHiColour=2291(bool useSetting, colour fore)
+enu Accessibility=SC_ACCESSIBILITY_
+val SC_ACCESSIBILITY_DISABLED=0
+val SC_ACCESSIBILITY_ENABLED=1
+
+# Enable or disable accessibility.
+set void SetAccessibility=2702(int accessibility,)
+
+# Report accessibility status.
+get int GetAccessibility=2703(,)
+
## New messages go here
## Start of key messages
diff -r 6c62b379a52e -r 23546875480b src/Editor.cxx
--- a/src/Editor.cxx Tue Mar 07 15:54:33 2017 +1100
+++ b/src/Editor.cxx Tue Mar 07 22:20:45 2017 +1100
@@ -7554,6 +7554,13 @@
std::vector<EdgeProperties>().swap(vs.theMultiEdge); // Free vector and memory, C++03 compatible
InvalidateStyleRedraw();
break;
+
+ case SCI_GETACCESSIBILITY:
+ return SC_ACCESSIBILITY_DISABLED;
+
+ case SCI_SETACCESSIBILITY:
+ // May be implemented by platform code.
+ break;
case SCI_GETDOCPOINTER:
return reinterpret_cast<sptr_t>(pdoc);
|