Skip to main content

HeightIndex

Struct HeightIndex 

Source
pub struct HeightIndex { /* private fields */ }
Expand description

Chunked prefix-sum index over row heights.

Implementations§

Source§

impl HeightIndex

Source

pub fn new() -> HeightIndex

Source

pub fn len(&self) -> usize

Number of rows.

Source

pub fn is_empty(&self) -> bool

Source

pub fn total_height(&mut self) -> u64

Total height of every row, in pixels.

Source

pub fn height_at(&self, row: usize) -> u32

Height of one row.

Source

pub fn is_measured(&self, row: usize) -> bool

Whether row row’s height came from a real layout pass.

Source

pub fn unmeasured_count(&self) -> usize

How many rows still carry an estimated height.

The view uses this to decide whether an idle-time measure backfill is worth scheduling.

Source

pub fn push_back(&mut self, height: u32, measured: bool)

Append a row.

Source

pub fn push_front(&mut self, height: u32, measured: bool)

Prepend a row — the chat-history backfill path.

Source

pub fn insert(&mut self, row: usize, height: u32, measured: bool)

Insert at an arbitrary row position.

Used by the Load-Older path, which inserts before a saved divider that is generally not at the front (server notices precede it, live messages follow it). O(chunk length) rather than O(n): only the containing chunk shifts, and the chunk prefixes past it are marked stale rather than recomputed.

Source

pub fn remove(&mut self, row: usize) -> Option<u32>

Remove a row, returning its height.

Source

pub fn drain_front(&mut self, n: usize)

Drop the first n rows — the scrollback trim.

Source

pub fn set_height(&mut self, row: usize, height: u32, measured: bool)

Replace a row’s height, e.g. when a real layout pass supersedes an estimate or an image texture finally lands.

Source

pub fn invalidate_all_measurements(&mut self)

Mark every row unmeasured, keeping the current heights as estimates.

This is a width or font change. Note what it does not do: re-measure anything. The old heights stay as the estimate so the scrollbar remains plausible, and rows are re-laid-out lazily as they become visible. That is the whole reason resize is O(visible) here and O(scrollback) in xtext.

Source

pub fn offset_of(&mut self, row: usize) -> u64

Pixel offset of the top of row row.

Source

pub fn locate(&mut self, y: u64) -> Option<Hit>

Which row contains pixel offset y, and how far into it.

y past the end clamps to the last row’s bottom edge, so a caller that over-scrolls gets a sane answer rather than None.

Trait Implementations§

Source§

impl Debug for HeightIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HeightIndex

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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