pub struct DisplayMap<'a> { /* private fields */ }Expand description
A view’s rows over its document.
Implementations§
Source§impl<'a> DisplayMap<'a>
impl<'a> DisplayMap<'a>
pub fn new(buffer: &'a Buffer, view: &'a View) -> Self
pub fn doc(&self) -> &'a Document
Sourcepub fn rows_in_line(&self, line: usize) -> usize
pub fn rows_in_line(&self, line: usize) -> usize
Rows that line takes on screen: 0 for a hidden line.
Sourcepub fn text_sub(&self, row: RowPos) -> Option<usize>
pub fn text_sub(&self, row: RowPos) -> Option<usize>
Which row of its line’s text row is, or None for a blank
(padding) row.
Sourcepub fn visible_line_count(&self) -> usize
pub fn visible_line_count(&self) -> usize
Lines that are not hidden. Sizes the scrollbar.
Sourcepub fn visible_line_at(&self, index: usize) -> usize
pub fn visible_line_at(&self, index: usize) -> usize
The index-th line that is not hidden (0-based), or the last one.
pub fn first_row(&self) -> RowPos
pub fn last_row(&self) -> RowPos
Sourcepub fn clamp_row(&self, row: RowPos) -> RowPos
pub fn clamp_row(&self, row: RowPos) -> RowPos
The nearest real row: a line past the end becomes the last line, a hidden line its fold’s header, and a row past the line’s last row (after the text or the width changed) that last row.
Sourcepub fn step(&self, row: RowPos, n: isize) -> (RowPos, isize)
pub fn step(&self, row: RowPos, n: isize) -> (RowPos, isize)
The row n rows after row (before it for negative n), stopping at
the first and last rows, and how many rows it actually moved.
Sourcepub fn advance(&self, row: RowPos, n: isize) -> RowPos
pub fn advance(&self, row: RowPos, n: isize) -> RowPos
The row n rows after row, clamped to the document.
Sourcepub fn row_range(&self, row: RowPos) -> Range<ByteOffset> ⓘ
pub fn row_range(&self, row: RowPos) -> Range<ByteOffset> ⓘ
The text shown on row, without the line break. A row that ends at a
wrap point ends where the next row starts.
Sourcepub fn is_last_in_line(&self, row: RowPos) -> bool
pub fn is_last_in_line(&self, row: RowPos) -> bool
Whether row is the last row of its line’s text (padding rows count
as last).
Sourcepub fn row_end(&self, row: RowPos) -> ByteOffset
pub fn row_end(&self, row: RowPos) -> ByteOffset
The last caret position on row. A position at a wrap point shows
at the start of the next row, so a row that wraps ends one grapheme
before it.
Sourcepub fn row_cols(&self, row: RowPos) -> (usize, usize)
pub fn row_cols(&self, row: RowPos) -> (usize, usize)
The line’s visual column where row starts, and the cells the row
is indented by on screen (continuation rows only).
Sourcepub fn row_indent(&self, row: RowPos) -> usize
pub fn row_indent(&self, row: RowPos) -> usize
Cells the text of row is indented by (continuation rows only).
Sourcepub fn row_of(&self, pos: ByteOffset) -> RowPos
pub fn row_of(&self, pos: ByteOffset) -> RowPos
The row showing pos; for a position hidden by a fold, the fold’s
header row.
Sourcepub fn col_in_row(&self, pos: ByteOffset) -> VisualCol
pub fn col_in_row(&self, pos: ByteOffset) -> VisualCol
The on-screen column of pos within its row, counting a
continuation row’s indent, so that Up and Down keep carets above
each other.
Sourcepub fn byte_at_col(&self, row: RowPos, col: VisualCol) -> ByteOffset
pub fn byte_at_col(&self, row: RowPos, col: VisualCol) -> ByteOffset
The position at on-screen column col of row, or the row’s end if
it is shorter.
Sourcepub fn offset_of(&self, row: RowPos, frac: f32) -> f64
pub fn offset_of(&self, row: RowPos, frac: f32) -> f64
A scroll position as a number of visible lines from the top, for the
scrollbar: the visible lines above row’s line, plus the part of that
line scrolled past.
Sourcepub fn pos_at_offset(&self, offset: f64) -> (RowPos, f32)
pub fn pos_at_offset(&self, offset: f64) -> (RowPos, f32)
The inverse of offset_of: the top row and fraction
for a scrollbar offset.
Sourcepub fn scroll_by(&self, row: RowPos, frac: f32, rows: f64) -> (RowPos, f32)
pub fn scroll_by(&self, row: RowPos, frac: f32, rows: f64) -> (RowPos, f32)
Scrolls a (top row, fraction) position by rows, which may be
fractional. Hitting the first row leaves no fraction; the caller
clamps the bottom with max_top.