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
commitca6ad60c453ecc2a79458c24dc38a1b46d55cf8b (patch)
tree859179d242083296937f19eea60bc2a8a4333044 /gtk/ScintillaGTKAccessible.cxx
parent49ce685da58519c39ab5de8aafe5c9fbedcbd5e1 (diff)
downloadscintilla-mirror-ca6ad60c453ecc2a79458c24dc38a1b46d55cf8b.tar.gz
Backport: 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. Backport of changeset 7405:01aab5f24e50.
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 b7d52a221..7e93b8a5e 100644
--- a/gtk/ScintillaGTKAccessible.cxx
+++ b/gtk/ScintillaGTKAccessible.cxx
@@ -162,6 +162,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);
}
@@ -865,10 +866,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) {
@@ -876,13 +879,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);