aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk/ScintillaGTKAccessible.cxx
diff options
context:
space:
mode:
authorColomban Wendling <ban@herbesfolles.org>2019-04-05 14:06:48 +0200
committerColomban Wendling <ban@herbesfolles.org>2019-04-05 14:06:48 +0200
commit5f23a0f3f64fb575e0aaebe2a309518909db44c8 (patch)
tree82e039de464e9dcfbe66f1a9391de129d62c5ce5 /gtk/ScintillaGTKAccessible.cxx
parent1219f761ef3a4bf048819c915f0465c35aeb7920 (diff)
downloadscintilla-mirror-5f23a0f3f64fb575e0aaebe2a309518909db44c8.tar.gz
Bug [#2094]. gtk: Accessible: use the built-in character position cache
It's quite a lot faster even after trying and optimizing the custom version, and it makes the code simpler. Also improve ByteOffsetFromCharacterOffset() to make use of the cache, making it drastically faster.
Diffstat (limited to 'gtk/ScintillaGTKAccessible.cxx')
-rw-r--r--gtk/ScintillaGTKAccessible.cxx16
1 files changed, 6 insertions, 10 deletions
diff --git a/gtk/ScintillaGTKAccessible.cxx b/gtk/ScintillaGTKAccessible.cxx
index 5f2979894..714fde10d 100644
--- a/gtk/ScintillaGTKAccessible.cxx
+++ b/gtk/ScintillaGTKAccessible.cxx
@@ -163,6 +163,7 @@ ScintillaGTKAccessible::ScintillaGTKAccessible(GtkAccessible *accessible_, GtkWi
sci(ScintillaGTK::FromWidget(widget_)),
deletionLengthChar(0),
old_pos(-1) {
+ SetAccessibility(true);
g_signal_connect(widget_, "sci-notify", G_CALLBACK(SciNotify), this);
}
@@ -866,10 +867,12 @@ void ScintillaGTKAccessible::NotifyReadOnly() {
#endif
}
-void ScintillaGTKAccessible::SetAccessibility() {
+void ScintillaGTKAccessible::SetAccessibility(bool enabled) {
// Called by ScintillaGTK when application has enabled or disabled accessibility
- character_offsets.resize(0);
- character_offsets.push_back(0);
+ if (enabled)
+ sci->pdoc->AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF32);
+ else
+ sci->pdoc->ReleaseLineCharacterIndex(SC_LINECHARACTERINDEX_UTF32);
}
void ScintillaGTKAccessible::Notify(GtkWidget *, gint, SCNotification *nt) {
@@ -877,13 +880,6 @@ void ScintillaGTKAccessible::Notify(GtkWidget *, gint, SCNotification *nt) {
return;
switch (nt->nmhdr.code) {
case SCN_MODIFIED: {
- if (nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
- // invalidate character offset cache if applicable
- const Sci::Line 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);