pub struct TocState {
pub scroll_offset: usize,
pub hovered_entry: Option<usize>,
pub hovered: bool,
pub entries: Vec<TocEntry>,
}markdown-preview only.Expand description
State for the Table of Contents sidebar.
Manages scroll position, hover state, and TOC entries.
Fields§
§scroll_offset: usizeCurrent scroll offset within the TOC.
hovered_entry: Option<usize>Index of the currently hovered entry, if any.
hovered: boolWhether the TOC itself is hovered.
entries: Vec<TocEntry>List of TOC entries extracted from the document.
Implementations§
Source§impl TocState
Entry management methods for TocState.
impl TocState
Entry management methods for TocState.
Sourcepub fn set_entries(&mut self, entries: Vec<TocEntry>)
pub fn set_entries(&mut self, entries: Vec<TocEntry>)
Set the TOC entries.
Sourcepub fn clear_entries(&mut self)
pub fn clear_entries(&mut self)
Clear all TOC entries.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Get the number of entries.
Sourcepub fn has_entries(&self) -> bool
pub fn has_entries(&self) -> bool
Check if the TOC has any entries.
Source§impl TocState
Extract TOC entries from markdown content.
impl TocState
Extract TOC entries from markdown content.
Sourcepub fn from_content(content: &str) -> TocState
pub fn from_content(content: &str) -> TocState
Sourcepub fn update_from_content(&mut self, content: &str)
pub fn update_from_content(&mut self, content: &str)
Source§impl TocState
Hover methods for TocState.
impl TocState
Hover methods for TocState.
Sourcepub fn is_hovered(&self) -> bool
pub fn is_hovered(&self) -> bool
Check if the TOC is currently hovered.
Sourcepub fn set_hovered(&mut self, hovered: bool)
pub fn set_hovered(&mut self, hovered: bool)
Set the hover state of the TOC.
Sourcepub fn hovered_entry(&self) -> Option<usize>
pub fn hovered_entry(&self) -> Option<usize>
Get the currently hovered entry index, if any.
Sourcepub fn set_hovered_entry(&mut self, index: Option<usize>)
pub fn set_hovered_entry(&mut self, index: Option<usize>)
Set the hovered entry index.
Sourcepub fn is_entry_hovered(&self, index: usize) -> bool
pub fn is_entry_hovered(&self, index: usize) -> bool
Check if a specific entry is hovered.
Source§impl TocState
Scroll methods for TocState.
impl TocState
Scroll methods for TocState.
Sourcepub fn scroll_offset(&self) -> usize
pub fn scroll_offset(&self) -> usize
Get the current scroll offset.
Sourcepub fn set_scroll_offset(&mut self, offset: usize)
pub fn set_scroll_offset(&mut self, offset: usize)
Set the scroll offset.
Sourcepub fn scroll_down(&mut self, amount: usize)
pub fn scroll_down(&mut self, amount: usize)
Scroll down by a given amount, clamping at max entries.
Sourcepub fn scroll_to_top(&mut self)
pub fn scroll_to_top(&mut self)
Scroll to the top.
Sourcepub fn scroll_to_bottom(&mut self)
pub fn scroll_to_bottom(&mut self)
Scroll to the bottom.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TocState
impl RefUnwindSafe for TocState
impl Send for TocState
impl Sync for TocState
impl Unpin for TocState
impl UnsafeUnpin for TocState
impl UnwindSafe for TocState
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
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 more