The
TextHitInfo
class represents a character position in a
text model, and a
bias, or "side," of the character. Biases are
either
leading (the left edge, for a left-to-right character)
or
trailing (the right edge, for a left-to-right character).
Instances of
TextHitInfo
are used to specify caret and
insertion positions within text.
For example, consider the text "abc". TextHitInfo.trailing(1)
corresponds to the right side of the 'b' in the text.
Sometimes it is convenient to construct a TextHitInfo
with
the same insertion offset as an existing one, but on the opposite
character. The getOtherHit
method constructs a new
TextHitInfo
with the same insertion offset as an existing
one, with a hit on the character on the other side of the insertion offset.
Calling getOtherHit
on trailing(1) would return leading(2).
In general, getOtherHit
for trailing(n) returns
leading(n+1) and getOtherHit
for leading(n)
returns trailing(n-1).