pub struct BlockLayouts(/* private fields */);Expand description
Where each block’s text landed, recorded as it painted.
A caret has to be placeable by pointer, and only paint knows where a glyph ended up. An editor hands one of these in, the renderer fills it, and the next click resolves against it. Read-only callers pass nothing and pay nothing.
Implementations§
Source§impl BlockLayouts
impl BlockLayouts
Sourcepub fn hit(&self, point: Point<Pixels>) -> Option<Cursor>
pub fn hit(&self, point: Point<Pixels>) -> Option<Cursor>
The position under point.
Falls back to the nearest text vertically, so clicking the margin beside a line — or below the last one — still lands somewhere useful rather than doing nothing.
Sourcepub fn position(&self, at: Cursor) -> Option<(Point<Pixels>, Pixels)>
pub fn position(&self, at: Cursor) -> Option<(Point<Pixels>, Pixels)>
Where a position painted last frame, and how tall its line is.
Vertical motion is geometry rather than arithmetic on line numbers, so
a wrapped row and a hard newline are the same case and neither needs
counting — the rule ui::TextField arrived at.
Sourcepub fn rects(&self, selection: Selection) -> Vec<Bounds<Pixels>>
pub fn rects(&self, selection: Selection) -> Vec<Bounds<Pixels>>
The painted rows of a range, in document order — what a bar centred over a selection is placed against, and what a highlight of a caller’s own is drawn from.
One rect per visual row rather than one box: a selection that wraps or crosses blocks has no single box, and a caller given one would paint over the gaps.
Sourcepub fn step_row(
&self,
at: Cursor,
from: Point<Pixels>,
down: bool,
) -> Option<(Cursor, Pixels)>
pub fn step_row( &self, at: Cursor, from: Point<Pixels>, down: bool, ) -> Option<(Cursor, Pixels)>
The position one painted row above or below at, and the row it landed
on. Walks the recorded runs in paint order — which is document order.
Two things make this refuse to be a hit test. The gap between blocks
belongs to no run, so a probe there answers with whichever run is
nearest — and at a boundary that is the block being left, whose bottom
edge is zero pixels away while the next block’s top is a whole gap. And
from is passed in rather than derived from at, because an offset at
a soft wrap belongs to two rows and position_for_index always answers
with the first: derive it and every step down recomputes the same row.
Sourcepub fn over_text(&self, point: Point<Pixels>) -> bool
pub fn over_text(&self, point: Point<Pixels>) -> bool
Whether point is inside painted text.
Self::hit answers with the nearest run wherever it is asked, which
is what a click wants and what a pointer must not have: an I-beam
belongs where a caret would land, not everywhere an editor’s box
reaches.
Sourcepub fn block_at(&self, point: Point<Pixels>) -> Option<usize>
pub fn block_at(&self, point: Point<Pixels>) -> Option<usize>
The block under point, for a gutter handle and a drop target.
Sourcepub fn first_row(&self, ix: usize) -> Option<(Pixels, Pixels)>
pub fn first_row(&self, ix: usize) -> Option<(Pixels, Pixels)>
Where a block’s first painted row sits, and how tall that row is — what a mark in the gutter has to line up with.
Self::block_bounds is not that: it spans every row the block holds,
and a heading’s single row is taller than a paragraph’s, so anything
placed from the top of the box rides above the text it points at.
None for a block that paints no text at all, a rule being the one
that does.
Sourcepub fn block_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
pub fn block_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
Where a block painted last frame, in window coordinates.
Sourcepub fn language_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
pub fn language_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
Where a fenced block’s language label painted — the box a host hangs its picker on. Recorded rather than derived: the word’s width is the text system’s answer, and padding arithmetic would be wrong the first time any of it changed.
Sourcepub fn picture_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
pub fn picture_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
Where an image block’s picture painted, which
BlockLayouts::block_bounds does not give: that box spans the column
and takes in the caption, so a handle placed from it sits off the edge
of any picture narrower than the page.
Trait Implementations§
Source§impl Clone for BlockLayouts
impl Clone for BlockLayouts
Source§fn clone(&self) -> BlockLayouts
fn clone(&self) -> BlockLayouts
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for BlockLayouts
impl Default for BlockLayouts
Source§fn default() -> BlockLayouts
fn default() -> BlockLayouts
Auto Trait Implementations§
impl !RefUnwindSafe for BlockLayouts
impl !Send for BlockLayouts
impl !Sync for BlockLayouts
impl !UnwindSafe for BlockLayouts
impl Freeze for BlockLayouts
impl Unpin for BlockLayouts
impl UnsafeUnpin for BlockLayouts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().