Skip to main content

DisplayMap

Struct DisplayMap 

Source
pub struct DisplayMap<'a> { /* private fields */ }
Expand description

A view’s rows over its document.

Implementations§

Source§

impl<'a> DisplayMap<'a>

Source

pub fn new(buffer: &'a Buffer, view: &'a View) -> Self

Source

pub fn doc(&self) -> &'a Document

Source

pub fn wraps(&self) -> bool

Whether lines wrap.

Source

pub fn rows_in_line(&self, line: usize) -> usize

Rows that line takes on screen: 0 for a hidden line.

Source

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.

Source

pub fn is_filler(&self, row: RowPos) -> bool

Whether row is a blank padding row.

Source

pub fn visible_line_count(&self) -> usize

Lines that are not hidden. Sizes the scrollbar.

Source

pub fn visible_line_at(&self, index: usize) -> usize

The index-th line that is not hidden (0-based), or the last one.

Source

pub fn first_row(&self) -> RowPos

Source

pub fn last_row(&self) -> RowPos

Source

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.

Source

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.

Source

pub fn advance(&self, row: RowPos, n: isize) -> RowPos

The row n rows after row, clamped to the document.

Source

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.

Source

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).

Source

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.

Source

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).

Source

pub fn row_indent(&self, row: RowPos) -> usize

Cells the text of row is indented by (continuation rows only).

Source

pub fn row_of(&self, pos: ByteOffset) -> RowPos

The row showing pos; for a position hidden by a fold, the fold’s header row.

Source

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.

Source

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.

Source

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.

Source

pub fn pos_at_offset(&self, offset: f64) -> (RowPos, f32)

The inverse of offset_of: the top row and fraction for a scrollbar offset.

Source

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.

Source

pub fn max_top(&self, rows_full: usize) -> RowPos

The lowest top row that still fills a viewport of rows_full rows (the first row when the document is shorter).

Source

pub fn rows_from( &self, top: RowPos, limit: usize, ) -> impl Iterator<Item = RowPos> + '_

Rows from top (inclusive) down, at most limit.

Trait Implementations§

Source§

impl<'a> Clone for DisplayMap<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for DisplayMap<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for DisplayMap<'a>

§

impl<'a> !Send for DisplayMap<'a>

§

impl<'a> !Sync for DisplayMap<'a>

§

impl<'a> !UnwindSafe for DisplayMap<'a>

§

impl<'a> Freeze for DisplayMap<'a>

§

impl<'a> Unpin for DisplayMap<'a>

§

impl<'a> UnsafeUnpin for DisplayMap<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.