Table of Contents
TextView widgets and their associated
provide a powerful framework for multiline text editing.
TextBuffer (see Section 13.3, “Text Buffers”) contains the text which is displayed by
one or more
Within GTK+ 2.0, text is encoded in UTF-8 which means that one
character may be encoded as multiple bytes. Within a
TextBuffer it is necessary to differentiate between
the character counts (called offsets) and the byte counts (called
TextIters provide a volatile representation
of the position in a
TextBuffer between two
TextIters are valid until the number of
characters in the
TextBuffer changes; i.e. any time
characters are inserted or deleted from a
TextIters will become invalid.
TextIters are the primary way to specify locations in
TextBuffer for manipulating text.
TextMarks are provided to allow
TextBuffer positions across buffer
modifications. A mark is like a
TextIter (see Section 13.4, “Text Iters”) in that it represents a position between
two characters in a
TextBuffer) but if the text
surrounding the mark is deleted the mark remains where the deleted text once
was. Likewise, if text is inserted at the mark the mark ends up either to
the left or right of the inserted text depending on the gravity of the mark
- right gravity leaves the mark to the right of the inserted text while left
gravity leaves it to the left.
TextMarks (see Section 13.5, “Text Marks”) may be named or anonymous if not given a
TextBuffer has two predefined named
TextMarks (see Section 13.5, “Text Marks”)
selection_bound. These refer to the insertion point
and the boundary of the selection (the selection is between the
insert and the
TextTags (see Section 13.6.1, “Text Tags”) are objects that specify a set of attributes
that can be applied to a range of text in a
TextTagTable (see Section 13.6.2, “Text Tag Tables”) which contains the tags that are
available in that buffer.
TextTagTables can be shared
TextBuffers to provide
TextTags are generally used to change
the appearance of a range of text but can also be used to prevent a range of
text from being edited.