package matrix
Build not checkedInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=ab48bc02082f9c1deea0769a13c2935df529536630745ec3a3d718f59656109b
sha512=c0f3c490e13ca60217d9d59c9bfdf3ada12e1565f04fe2a623e7c94298d519393eabe404e2317726712bf5e7fa860780a07494e77994ac05032e71f535c56910
doc/matrix.text/Matrix_text/Layout/Source/index.html
Module Layout.SourceSource
Texts indexed by grapheme cluster and logical line.
A source keeps its text's bytes as they are, and indexes every cluster, those of width 0 included. CR LF is one cluster of two bytes. A source indexes each logical line, and a source made by edit shares the index of every line the edit leaves whole with the source it was made from. A line that holds more than printable ASCII has its clusters indexed when something first asks about it, with their widths by the width method and tab width it was last laid out with. A source also keeps its layouts (Layout.create). Sources made from one another share what they cache, so they must not be used by two domains in parallel.
The type for sources.
grapheme_of_byte t ~affinity b is the boundary at byte offset b, clamped to the text. An offset inside a cluster gives the boundary before it if affinity is Upstream, and after it if Downstream.
line_count t is the number of logical lines of t, empty ones and an empty last line included. It is at least 1.
line_end t line is the boundary before the line terminator of line, or the end of t for the last line.
val columns :
?width_method:width_method ->
?tab_width:int ->
t ->
first:int ->
last:int ->
intcolumns t ~first ~last is the width of the clusters from boundary first to boundary last, negative if last is before first.
slice t ~first ~last is a copy of the bytes from boundary first to boundary last, and "" if last is not after first.
edit t ~first ~last s is the source of t's text with the bytes from first to last replaced by s. It copies the text, indexes again the lines the replacement touches, and shares the index of the others with t, which is unchanged.
Raises Invalid_argument unless 0 <= first <= last <= String.length (text t).