# HG changeset patch
# User Neil
# 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 @@
○ Long lines |
+ ○ Accessibility |
+
○ Lexer |
+
+
+
○ Lexer objects |
-
-
-
○ Notifications |
- ○ Accessibility |
-
○ Images |
@@ -6511,6 +6511,60 @@
of a space character in STYLE_DEFAULT
. All the edges can be cleared with
SCI_MULTIEDGECLEARALL
.
+ Accessibility
+
+ 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.
+
+
+ SCI_SETACCESSIBILITY(int accessibility)
+ SCI_GETACCESSIBILITY → int
+
+
+ SCI_SETACCESSIBILITY(int accessibility)
+ SCI_GETACCESSIBILITY → int
+ These messages may enable or disable accessibility and report its current status.
+
+ On most platforms, accessibility is either implemented or not implemented and this can be
+ discovered with SCI_GETACCESSIBILITY
with
+ SCI_SETACCESSIBILITY
performing no action.
+ On GTK+, there are storage and performance costs to accessibility, so it can be disabled
+ by calling SCI_SETACCESSIBILITY
.
+
+
+
+
+
+ Symbol |
+
+ Value |
+
+ Accessibility status |
+
+
+
+
+
+ SC_ACCESSIBILITY_DISABLED |
+
+ 0 |
+
+ Accessibility is disabled. |
+
+
+
+ SC_ACCESSIBILITY_ENABLED |
+
+ 1 |
+
+ Accessibility is enabled. |
+
+
+
+
Lexer
If you define the symbol SCI_LEXER
when building Scintilla, (this is sometimes
@@ -7891,15 +7945,6 @@
SCN_AUTOCSELECTION
notification.
- Accessibility
-
- 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.
-
-
Images
Two formats are supported for images used in margin markers and autocompletion lists, RGBA and XPM.
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.
+ Accessibility support may be queried with SCI_GETACCESSIBILITY.
+ On GTK+, accessibility may be disabled by calling SCI_SETACCESSIBILITY.
+
+
Lexer added for "indent" language which is styled as plain text but folded by indentation level.
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(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 character_offsets;
+ // cache holding character offset for each line start, see CharacterOffsetFromByteOffset()
+ std::vector character_offsets;
+
// cached length of the deletion, in characters (see Notify())
int deletionLengthChar;
// local state for comparing
Position old_pos;
std::vector 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().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(pdoc);