pub struct MarkdownEditorView {
pub layout: Layout,
pub text_snapshot: Text,
pub cursor_snapshot: (usize, usize),
pub last_cursor_screen: Option<(u16, u16)>,
/* private fields */
}Fields§
§layout: Layout§text_snapshot: TextThe text the caches below were built from.
Held rather than borrowed because render runs without the frame’s
snapshot in scope. Keeping it costs nothing: a Text clone shares its
structure, so this is the same text rather than a copy of it — which is why
the twenty lines that used to copy changed rows into a Vec<String> are
now one assignment.
cursor_snapshot: (usize, usize)§last_cursor_screen: Option<(u16, u16)>Cursor’s last on-screen position (col, row), or None when the
cursor was scrolled off-screen or the view was unfocused at the
time of the previous render. Used as the anchor for floating
overlays like the autocomplete popup, which is drawn after the
editor itself.
Implementations§
Source§impl MarkdownEditorView
impl MarkdownEditorView
pub fn new() -> Self
Sourcepub fn last_parse_was_incremental(&self) -> bool
pub fn last_parse_was_incremental(&self) -> bool
Returns Some(generation) if Gate 1 just installed a
placeholder ParsedBuffer and the owning component should
spawn a background full parse for this generation. Consumes
the flag so the owner does not spawn twice; the owner is
responsible for calling install_full_parse when the task
completes.
Whether the most recent Gate 1 invocation took the incremental
splice path. Read-only diagnostic for the incremental-parse
property tests (tui/tests/incremental_property.rs); not part
of the production render path.
pub fn take_pending_full_parse(&mut self) -> Option<u64>
Sourcepub fn install_full_parse(&mut self, generation: u64, buf: ParsedBuffer)
pub fn install_full_parse(&mut self, generation: u64, buf: ParsedBuffer)
Install the result of a background full parse. No-op when
the editor has advanced past generation — that result is
stale and a fresh spawn is already in flight. Invalidates the
layout + rendered_cache so the next update() rebuilds Gate
2 against the fresh ParsedBuffer.
Sourcepub fn take_pending_full_layout(&mut self) -> Option<PendingLayoutJob>
pub fn take_pending_full_layout(&mut self) -> Option<PendingLayoutJob>
Returns Some(job) if Gate 2 just installed a Layout::unwrapped
stub and the owning component should spawn a background
Layout::compute for it. Consumes the flag so the owner does not
spawn twice; the owner is responsible for calling
install_full_layout when the task completes.
Sourcepub fn install_full_layout(&mut self, generation: u64, layout: Layout)
pub fn install_full_layout(&mut self, generation: u64, layout: Layout)
Install the result of a background Layout::compute. No-op when the
editor has advanced past generation (a fresh spawn is already in
flight — mirrors install_full_parse’s staleness gate) or when the
pane was resized since the job was captured (layout.width() no
longer matches last_layout_width — a generation match alone
cannot catch this, since a resize with no content change never
bumps content_revision).
Sourcepub fn set_overlays(&mut self, overlays: Vec<Overlay>)
pub fn set_overlays(&mut self, overlays: Vec<Overlay>)
Hand the view this frame’s overlays, in logical coordinates. Must be
called after update, which clears them.
The view appends the two kinds it derives itself — task decorations and needle emphasis. Those come from the lines it already holds, and it is the only thing that knows which rows are visible, so scanning them anywhere else would mean shipping the viewport outward.
Sourcepub fn set_needles(&mut self, needles: Vec<String>)
pub fn set_needles(&mut self, needles: Vec<String>)
Vault-search needles to emphasise. Sticky across frames, unlike overlays: they come from the query that opened the note.
Sourcepub fn clear_visual_goal(&mut self)
pub fn clear_visual_goal(&mut self)
Declare that the edit just performed was a bulk one — it changed rows the cursor does not point at.
compute_damage_range’s fast path trusts the cursor row to be the only
edited row and will otherwise under-report the damage, leaving distant
rows rendered from a stale parse. Every edit that rewrites more than the
cursor’s neighbourhood must call this.
Forget where a run of ↑/↓ was aiming. Any other cursor movement ends it.
Sourcepub fn move_cursor_visually(
&mut self,
buf: &mut RopeBuffer,
down: bool,
extend: bool,
) -> bool
pub fn move_cursor_visually( &mut self, buf: &mut RopeBuffer, down: bool, extend: bool, ) -> bool
Move the cursor one drawn line, which is what an arrow key means in a wrapped editor: one press moves one line the reader can see, not past the whole remainder of a soft-wrapped paragraph.
Lives on the view because only the view has the layout — the buffer holds the text and the cursor, and neither alone can answer “which line is this drawn on”. That split is exactly why the incumbent could not do this.
Returns false when the layout does not describe the buffer’s current
text — an edit lands before the frame that re-lays it out — and the caller
falls back to a logical move rather than reading a stale layout.
Sourcepub fn note_damage(&mut self, rows: Range<usize>, line_delta: isize)
pub fn note_damage(&mut self, rows: Range<usize>, line_delta: isize)
Record which rows an edit changed, for the next update to act on.
line_delta is what this edit did to the row count. Several edits can
land between two frames, and a range recorded before one of them that
moved rows no longer means what it said — so the accumulated hull is
brought into the new numbering first. This matters more than it used to:
the layout now patches across a line-count change rather than rebuilding,
so an under-reported hull leaves rows wrapped as they used to be.
pub fn note_bulk_edit(&mut self)
pub fn update(&mut self, snap: &EditorSnapshot, rect: Rect)
pub fn render( &mut self, f: &mut Frame<'_>, rect: Rect, theme: &Theme, focused: bool, cursor_shape: Option<CursorShape>, )
Sourcepub fn parsed_buffer_kinds(&self) -> &[LineConstructKind]
pub fn parsed_buffer_kinds(&self) -> &[LineConstructKind]
Test accessor: the kinds vector of the current parsed buffer. Used by the proptest harness to assert incremental = full parse.
Sourcepub fn parsed_buffer_lines(&self) -> &[ParsedLine]
pub fn parsed_buffer_lines(&self) -> &[ParsedLine]
Test accessor: the parsed lines of the current parsed buffer.
Sourcepub fn click_at_screen(
&self,
screen_row: usize,
screen_col: usize,
) -> (u16, u16)
pub fn click_at_screen( &self, screen_row: usize, screen_col: usize, ) -> (u16, u16)
Markdown-aware mouse click: maps a rendered screen column to the correct logical column, accounting for hidden markdown sigils (links, bold markers, etc.).
Reads self’s view-internal caches (layout, lines_snapshot,
parsed_buffer), all rebuilt from the same EditorSnapshot
in the last update() call. The snapshot invariant guarantees
vl.logical_row is a valid index into both lines_snapshot
and parsed_buffer.lines, so direct indexing is safe — the
previous defensive (Some, Some) else fallback block (Fix #2
in the holistic review) is no longer needed.
Map a screen-relative click (row/col offset from the editor’s
top-left corner) to logical (row, col). Owns the
visual-scroll-offset arithmetic so callers do not reach into
visual_scroll_offset — the view knows where it is scrolled.
Trait Implementations§
Source§impl Clone for MarkdownEditorView
impl Clone for MarkdownEditorView
Source§fn clone(&self) -> MarkdownEditorView
fn clone(&self) -> MarkdownEditorView
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MarkdownEditorView
impl RefUnwindSafe for MarkdownEditorView
impl Send for MarkdownEditorView
impl Sync for MarkdownEditorView
impl Unpin for MarkdownEditorView
impl UnsafeUnpin for MarkdownEditorView
impl UnwindSafe for MarkdownEditorView
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<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more