public class TextMark extends Object
TextIters are transient pointers to positions within TextBuffers which are
invalidated when their TextBuffer is modified, so you can't "save" them. If
you need to preserve a position for later reuse, then get a TextMark by
createMark() on it.
Instances of this class fill the same role for TextBuffers that
TreeRowReference does in providing stability for rows pointed to
transiently by TreeIters that come from TreeModels.
|Modifier and Type||Field and Description|
|Modifier and Type||Method and Description|
Get the TextBuffer that this TextMark points into.
Get a currently valid TextIter indicating where in the TextBuffer this TextMark is pointing.
public static final boolean LEFT
createMark(). The TextMark will stay fixed to the left if text is added there.
public TextBuffer getBuffer()
public TextIter getIter()
The usual caveats about changes invalidating iterators apply, but if
you use these inline you will have no problems. For example, given
end and a TextTag of some
sort, you could easily do:
buffer.applyTag(bold, start.getIter(), end.getIter());which is very straight forward. If you are using the same position repeatedly, however, and not changing the TextBuffer, then it is far more efficient to convert the TextMark into a TextIter once and use that directly.