diff options
-rw-r--r-- | gtk/ScintillaGTKAccessible.cxx | 7 | ||||
-rw-r--r-- | gtk/ScintillaGTKAccessible.h | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/gtk/ScintillaGTKAccessible.cxx b/gtk/ScintillaGTKAccessible.cxx index 3fdb22828..ecf843ce5 100644 --- a/gtk/ScintillaGTKAccessible.cxx +++ b/gtk/ScintillaGTKAccessible.cxx @@ -478,7 +478,7 @@ void ScintillaGTKAccessible::GetCharacterExtents(int charOffset, } else if (nextByteOffset > byteOffset) { /* maybe next position was on the next line or something. * just compute the expected character width */ - int style = sci->pdoc->StyleAt(byteOffset); + int style = StyleAt(byteOffset, true); int len = nextByteOffset - byteOffset; char *ch = new char[len + 1]; sci->pdoc->GetCharRange(ch, byteOffset, len); @@ -556,13 +556,14 @@ AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *s g_return_val_if_fail(byteOffset <= length, NULL); - const char style = sci->pdoc->StyleAt(byteOffset); + const char style = StyleAt(byteOffset, true); // compute the range for this style Position startByte = byteOffset; + // when going backwards, we know the style is already computed while (startByte > 0 && sci->pdoc->StyleAt((startByte) - 1) == style) (startByte)--; Position endByte = byteOffset + 1; - while (endByte < length && sci->pdoc->StyleAt(endByte) == style) + while (endByte < length && StyleAt(endByte, true) == style) (endByte)++; CharacterRangeFromByteRange(startByte, endByte, startChar, endChar); diff --git a/gtk/ScintillaGTKAccessible.h b/gtk/ScintillaGTKAccessible.h index 94430636b..fa9698417 100644 --- a/gtk/ScintillaGTKAccessible.h +++ b/gtk/ScintillaGTKAccessible.h @@ -73,6 +73,12 @@ private: return sci->pdoc->MovePositionOutsideChar(pos + 1, 1, true); } + int StyleAt(Position position, bool ensureStyle = false) { + if (ensureStyle) + sci->pdoc->EnsureStyledTo(position); + return sci->pdoc->StyleAt(position); + } + // For AtkText gchar *GetTextRangeUTF8(Position startByte, Position endByte); gchar *GetText(int startChar, int endChar); |