Expand description
Position newtypes and the conversions between them.
This is the only module that knows about tab stops, grapheme clusters and
display widths. The canonical position everywhere else is ByteOffset.
Structs§
- Byte
Offset - Byte offset into the document’s UTF-8 text, always on a char boundary.
- CharIdx
- Char index; only used at the boundary with Ropey 1.x.
- LineCol
- A line and a byte column within that line.
- Visual
Col - On-screen cell column, after tab expansion and wide-glyph widths.
- Wrapped
- How one line wraps into display rows.
Constants§
- MIN_
WRAP_ WIDTH - The narrowest wrap width, in cells.
Functions§
- byte_
to_ line_ col - byte_
to_ visual_ col - cells
- (byte, visual column, width in cells) of each grapheme of one line’s
text. - grapheme_
width - Display width of one grapheme starting at visual column
col. Tabs expand to the next tab stop; every other grapheme takes at least one cell so that distinct boundaries always have distinct visual columns. - line_
col_ to_ byte - Clamps the column to the end of the line. The column must land on a char boundary; out-of-range lines clamp to the end of the document.
- line_
visual_ width - Width of the whole line in visual columns.
- next_
grapheme_ boundary - The next grapheme boundary after
pos(or the end of the document). - prev_
grapheme_ boundary - The previous grapheme boundary before
pos(or 0). - visual_
col_ to_ byte - The last grapheme boundary on
linewhose visual column is<= col, or the line end if the line is shorter (no virtual space). - visual_
col_ to_ byte_ ceil - The first grapheme boundary on
linewhose visual column is>= col, or the line end. Used for the left edge of a rectangle so that a tab or wide glyph straddling the edge stays outside it. - wrap_
line - Wraps
text(one line, without its line break) to rows ofwidthcells. Rows break after a run of whitespace when there is one in the row, otherwise before the grapheme that does not fit; a grapheme is never split, and one wider than a row gets a row of its own. Tab stops count from the start of the line, so wrapping never changes a grapheme’s visual column. Rows after the first are indented like the line, by at most half the width.