pub struct MarkdownState {Show 18 fields
pub scroll: ScrollState,
pub source: SourceState,
pub cache: CacheState,
pub display: DisplaySettings,
pub collapse: CollapseState,
pub expandable: ExpandableState,
pub git_stats: GitStatsState,
pub vim: VimState,
pub selection: SelectionState,
pub double_click: DoubleClickState,
pub toc_hovered: bool,
pub toc_hovered_entry: Option<usize>,
pub toc_scroll_offset: usize,
pub selection_active: bool,
pub cached_git_stats: Option<GitStats>,
pub rendered_lines: Vec<Line<'static>>,
pub filter: Option<String>,
pub filter_mode: bool,
/* private fields */
}Expand description
Unified state for the markdown widget.
This struct bundles all component states together, making it easier to manage widget state without passing many individual references.
§Example
use ratatui_toolkit::markdown_widget::state::MarkdownState;
use ratatui_toolkit::MarkdownWidget;
let mut state = MarkdownState::default();
state.source.set_content("# Hello World");
let widget = MarkdownWidget::from_state(&mut state)
.show_toc(true)
.show_statusline(true);Fields§
§scroll: ScrollStateCore scroll state (position, viewport, current line).
source: SourceStateContent source state.
cache: CacheStateRender cache state.
display: DisplaySettingsDisplay settings (line numbers, themes).
collapse: CollapseStateSection collapse state.
expandable: ExpandableStateExpandable content state.
git_stats: GitStatsStateGit stats state.
vim: VimStateVim keybinding state.
selection: SelectionStateSelection state for text selection/copy.
double_click: DoubleClickStateDouble-click detection state.
toc_hovered: boolWhether the TOC is currently hovered.
toc_hovered_entry: Option<usize>Index of the hovered TOC entry.
toc_scroll_offset: usizeScroll offset for the TOC list.
selection_active: boolWhether selection mode is active.
cached_git_stats: Option<GitStats>Git statistics for the file (cached from git_stats state).
rendered_lines: Vec<Line<'static>>Cached rendered lines for selection text extraction. This persists between frames so mouse events can access line data.
filter: Option<String>Current filter text (when in filter mode).
filter_mode: boolWhether filter mode is currently active.
Implementations§
Source§impl MarkdownState
impl MarkdownState
Sourcepub fn inner_area(&self) -> Rect
Available on crate feature markdown-preview only.
pub fn inner_area(&self) -> Rect
markdown-preview only.Get the inner area for mouse event handling.
Returns the inner area that was set during the last render.
Sourcepub fn set_inner_area(&mut self, area: Rect)
Available on crate feature markdown-preview only.
pub fn set_inner_area(&mut self, area: Rect)
markdown-preview only.Set the inner area for mouse event handling.
This is typically called by the widget during render.
Sourcepub fn content(&self) -> &str
Available on crate feature markdown-preview only.
pub fn content(&self) -> &str
markdown-preview only.Get the content from the source state.
Returns the content if set, or an empty string.
Sourcepub fn update_git_stats(&mut self)
Available on crate feature markdown-preview only.
pub fn update_git_stats(&mut self)
markdown-preview only.Update git stats from the source path.
This should be called periodically to refresh git information.
Sourcepub fn reload_source_if_changed(&mut self) -> Result<bool, Error>
Available on crate feature markdown-preview only.
pub fn reload_source_if_changed(&mut self) -> Result<bool, Error>
markdown-preview only.Reload file content if the watcher detected changes.
Returns true when content changed and caches were invalidated.
Source§impl MarkdownState
Default implementation for MarkdownState.
impl MarkdownState
Default implementation for MarkdownState.
This module is kept for compatibility but Default is now derived on the MarkdownState struct directly. Constructor for MarkdownState.
Sourcepub fn new() -> MarkdownState
Available on crate feature markdown-preview only.
pub fn new() -> MarkdownState
markdown-preview only.Create a new MarkdownState with all default values.
This is equivalent to MarkdownState::default().
Sourcepub fn with_display(display: DisplaySettings) -> MarkdownState
Available on crate feature markdown-preview only.
pub fn with_display(display: DisplaySettings) -> MarkdownState
markdown-preview only.Create a new MarkdownState with custom display settings.
Trait Implementations§
Source§impl Clone for MarkdownState
impl Clone for MarkdownState
Source§fn clone(&self) -> MarkdownState
fn clone(&self) -> MarkdownState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for MarkdownState
impl Default for MarkdownState
Source§fn default() -> MarkdownState
fn default() -> MarkdownState
Auto Trait Implementations§
impl Freeze for MarkdownState
impl RefUnwindSafe for MarkdownState
impl Send for MarkdownState
impl !Sync for MarkdownState
impl Unpin for MarkdownState
impl UnsafeUnpin for MarkdownState
impl UnwindSafe for MarkdownState
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