module

Mica::Core::LineTracking

Line and column tracking for text formats, included next to ByteInput.

The scanner calls record_line_break after each line end it consumes (each format decides what a line end is). Columns are not counted while scanning: column_at counts the characters (UTF-8 lead bytes) between the line start and a position when one is asked for. A cache of the last answer makes repeated questions on the same line cost only the distance moved, so asking for the position after every event stays linear in the input size even on a single-line document.

Line and column numbers saturate at Int32::MAX (the byte offset in a Position stays exact), so a stream of any length cannot overflow them.

Constants

POSITION_STEP_CHUNK = 65536

Bytes counted between two calls of the step block of column_at.