The core text management data structure which supports efficient
modifications and provides a byte string interface. Text positions
are represented as size_t
. Valid addresses are in range [0,
text_size(txt)]
. An invalid position is denoted by EPOS. Access to
the non-contigiuos pieces is available by means of an iterator interface
or a copy mechanism. Text revisions are tracked in an history graph.
Note
The text is assumed to be encoded in UTF-8.
.. doxygengroup:: load :content-only:
.. doxygengroup:: state :content-only:
.. doxygengroup:: modify :content-only:
The individual pieces of the text are not necessarily stored in a contiguous memory block. These functions perform a copy to such a region.
.. doxygengroup:: access :content-only:
An iterator points to a given text position and provides interfaces to
adjust said position or read the underlying byte value. Functions which
take a char
pointer will generally assign the byte value after
the iterator was updated.
.. doxygenstruct:: Iterator
.. doxygengroup:: iterator :content-only:
Note
For a read attempt at EOF (i.e. text_size) an artificial NUL
byte which is not actually part of the file is returned.
.. doxygengroup:: iterator_byte :content-only:
These functions advance to the next/previous leading byte of an UTF-8
encoded Unicode codepoint by skipping over all continuation bytes of
the form 10xxxxxx
.
.. doxygengroup:: iterator_code :content-only:
These functions advance to the next/previous grapheme cluster.
Note
The grapheme cluster boundaries are currently not implemented according to UAX#29 rules. Instead a base character followed by arbitrarily many combining character as reported by wcwidth(3) are skipped.
.. doxygengroup:: iterator_char :content-only:
Translate between 1 based line numbers and 0 based byte offsets.
.. doxygengroup:: lines :content-only:
Interfaces to the history graph.
.. doxygengroup:: history :content-only:
A mark keeps track of a text position. Subsequent text changes will update all marks placed after the modification point. Reverting to an older text state will hide all affected marks, redoing the changes will restore them.
Warning
Due to an optimization cached modifications (i.e. no text_snaphot was performed between setting the mark and issuing the changes) might not adjust mark positions accurately.
.. doxygentypedef:: Mark
.. doxygendefine:: EMARK
.. doxygengroup:: mark :content-only:
.. doxygengroup:: save :content-only:
.. doxygengroup:: misc :content-only: