aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/ScintillaGTK.cxx14
-rw-r--r--gtk/ScintillaGTK.h1
-rw-r--r--gtk/ScintillaGTKAccessible.cxx23
-rw-r--r--gtk/ScintillaGTKAccessible.h5
4 files changed, 43 insertions, 0 deletions
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);