pub struct Cursor {
pub offset: usize,
pub logical_pos: Point,
pub visual_pos: Point,
pub column: CoordType,
pub wrap_opp: bool,
}Expand description
Stores a position inside a ReadableDocument.
The cursor tracks both the absolute byte-offset, as well as the position in terminal-related coordinates.
Fields§
§offset: usizeOffset in bytes within the buffer.
logical_pos: PointPosition in the buffer in lines (.y) and grapheme clusters (.x).
Line wrapping has NO influence on this.
visual_pos: PointPosition in the buffer in laid out rows (.y) and columns (.x).
Line wrapping has an influence on this.
column: CoordTypeHorizontal position in visual columns.
Line wrapping has NO influence on this and if word wrap is disabled,
it’s identical to visual_pos.x. This is useful for calculating tab widths.
wrap_opp: boolWhen measure_forward hits the word_wrap_column, the question is:
Was there a wrap opportunity on this line? Because if there wasn’t,
a hard-wrap is required; otherwise, the word that is being laid-out is
moved to the next line. This boolean carries this state between calls.