Skip to main content

MarkdownEditorView

Struct MarkdownEditorView 

Source
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: Text

The 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

Source

pub fn new() -> Self

Source

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.

Source

pub fn take_pending_full_parse(&mut self) -> Option<u64>

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn note_bulk_edit(&mut self)

Source

pub fn update(&mut self, snap: &EditorSnapshot, rect: Rect)

Source

pub fn render( &mut self, f: &mut Frame<'_>, rect: Rect, theme: &Theme, focused: bool, cursor_shape: Option<CursorShape>, )

Source

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.

Source

pub fn parsed_buffer_lines(&self) -> &[ParsedLine]

Test accessor: the parsed lines of the current parsed buffer.

Source

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

Source§

fn clone(&self) -> MarkdownEditorView

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for MarkdownEditorView

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more