a11y: Fix offset handling for AT-SPI GetCharacterAtOffset
The text retrieved using gtk_accessible_text_get_contents
already contains only the character at the given offset,
and so the character is at index 0 in str
, rather than at
the same offset again, so adjust this accordingly.
With this in place, querying the character in a LibreOffice paragraph consisting of the text "Hello world." now gives the expected results with a pending LibreOffice change to support the new GtkAccessibleText interface:
In [1]: text = acc.queryText()
In [2]: text.getCharacterAtOffset(0)
Out[2]: 72
In [3]: text.getCharacterAtOffset(1)
Out[3]: 101
In [4]: text.getCharacterAtOffset(2)
Out[4]: 108
In [5]: text.getCharacterAtOffset(3)
Out[5]: 108
In [6]: text.getCharacterAtOffset(4)
Out[6]: 111
Previously, this would only work correctly for an index of 0:
In [1]: text = acc.queryText()
In [2]: text.getCharacterAtOffset(0)
Out[2]: 72
In [3]: text.getCharacterAtOffset(1)
Out[3]: 0
In [4]: text.getCharacterAtOffset(2)
Out[4]: 0
In [5]: text.getCharacterAtOffset(3)
Out[5]: 0
In [6]: text.getCharacterAtOffset(4)
Out[6]: 0