diff options
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 3 | ||||
-rw-r--r-- | doc/ScintillaDoc.html | 71 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | gtk/ScintillaGTK.cxx | 14 | ||||
-rw-r--r-- | gtk/ScintillaGTK.h | 1 | ||||
-rw-r--r-- | gtk/ScintillaGTKAccessible.cxx | 23 | ||||
-rw-r--r-- | gtk/ScintillaGTKAccessible.h | 5 | ||||
-rw-r--r-- | include/Scintilla.h | 4 | ||||
-rw-r--r-- | include/Scintilla.iface | 10 | ||||
-rw-r--r-- | src/Editor.cxx | 7 |
10 files changed, 129 insertions, 13 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 1caed47da..cc5ee0fc7 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -906,6 +906,9 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar return r; } + case SCI_GETACCESSIBILITY: + return SC_ACCESSIBILITY_ENABLED; + default: sptr_t r = ScintillaBase::WndProc(iMessage, wParam, lParam); diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index a29bfe617..631b38eb8 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -367,16 +367,16 @@ <tr> <td>○ <a class="toc" href="#LongLines">Long lines</a></td> - <td>○ <a class="toc" href="#Lexer">Lexer</a></td> + <td>○ <a class="toc" href="#Accessibility">Accessibility</a></td> - <td>○ <a class="toc" href="#LexerObjects">Lexer objects</a></td> + <td>○ <a class="toc" href="#Lexer">Lexer</a></td> </tr> <tr> - <td>○ <a class="toc" href="#Notifications">Notifications</a></td> + <td>○ <a class="toc" href="#LexerObjects">Lexer objects</a></td> - <td>○ <a class="toc" href="#Accessibility">Accessibility</a></td> + <td>○ <a class="toc" href="#Notifications">Notifications</a></td> <td>○ <a class="toc" href="#Images">Images</a></td> @@ -6511,6 +6511,60 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ 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 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next <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 --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index a8bad7678..290ac3927 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -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 --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 35622bc02..46a4b488f 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -175,6 +175,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) : rgnUpdate(0), repaintFullWindow(false), styleIdleID(0), + accessibilityEnabled(SC_ACCESSIBILITY_ENABLED), accessible(0) { sci = sci_; wMain = GTK_WIDGET(sci); @@ -875,6 +876,19 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam 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 --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h index 6f69661f2..4ee55a6c8 100644 --- a/gtk/ScintillaGTK.h +++ b/gtk/ScintillaGTK.h @@ -68,6 +68,7 @@ class ScintillaGTK : public ScintillaBase { bool repaintFullWindow; guint styleIdleID; + int accessibilityEnabled; AtkObject *accessible; // Private so ScintillaGTK objects can not be copied diff --git a/gtk/ScintillaGTKAccessible.cxx b/gtk/ScintillaGTKAccessible.cxx index 4fcfcda99..001f2703f 100644 --- a/gtk/ScintillaGTKAccessible.cxx +++ b/gtk/ScintillaGTKAccessible.cxx @@ -788,6 +788,10 @@ void ScintillaGTKAccessible::AtkEditableTextIface::init(::AtkEditableTextIface * //~ 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::UpdateCursor() { } void ScintillaGTKAccessible::ChangeDocument(Document *oldDoc, Document *newDoc) { + if (!Enabled()) { + return; + } + if (oldDoc == newDoc) { return; } @@ -854,7 +862,15 @@ void ScintillaGTKAccessible::NotifyReadOnly() { #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 @@ void ScintillaGTKAccessible::Notify(GtkWidget *, gint, SCNotification *nt) { 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 --git a/gtk/ScintillaGTKAccessible.h b/gtk/ScintillaGTKAccessible.h index 88256e0ca..1905c0619 100644 --- a/gtk/ScintillaGTKAccessible.h +++ b/gtk/ScintillaGTKAccessible.h @@ -23,12 +23,16 @@ private: // 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 @@ public: // 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 --git a/include/Scintilla.h b/include/Scintilla.h index 6a36d24f4..b997c0a5b 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -593,6 +593,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #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 --git a/include/Scintilla.iface b/include/Scintilla.iface index 4c964e3fd..5aa5f8ee3 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1476,6 +1476,16 @@ fun void SetFoldMarginColour=2290(bool useSetting, colour back) # 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 --git a/src/Editor.cxx b/src/Editor.cxx index e5fbc69be..35bbc10fe 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7554,6 +7554,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { 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); |