LavaUI docs

struct LineIndex

Swift

struct LineIndex

Where each logical line sits, in characters and (optionally) in bytes.

Two coordinate systems for the same lines, because the editor genuinely needs both and they only agree while a buffer is ASCII: rows and carets are stated in characters, while comparing two buffers or slicing one line out of one is byte work. byteRanges is empty when the caller did not ask for it — see VisualLayout.lineIndex.

Sources/LavaText/SoftWrap.swift:81

Constructors

init(rows: [Range<Int>] = [], byteRanges: [Range<Int>] = [])

Not documented.

Sources/LavaText/SoftWrap.swift:87

Properties

var byteRanges: [Range<Int>]

The same lines as byte ranges, or empty.

Sources/LavaText/SoftWrap.swift:85

var rows: [Range<Int>]

Character range of each line, its newline excluded.

Sources/LavaText/SoftWrap.swift:83

Methods

func line(atByte byte: Int) -> Int

Line containing byte, or the last line when it is past the end.

Binary search: an edit is located in bytes and has to be turned into line numbers, and doing that by walking would put the buffer's length back into the cost of a keystroke.

Sources/LavaText/SoftWrap.swift:97