Skip to main content

DocView

Struct DocView 

Source
pub struct DocView {
Show 16 fields pub rows: Vec<Row>, pub tables: Vec<TableView>, pub directives: Vec<DirectiveView>, pub media: Vec<MediaView>, pub caret_row: u32, pub caret_col: u32, pub caret_ch: u32, pub caret_src: u32, pub has_selection: bool, pub anchor_row: u32, pub anchor_ch: u32, pub dirty: bool, pub view: String, pub heading: Option<u32>, pub active: Vec<String>, pub link: Option<String>,
}
Expand description

A whole rendered frame: the rows to paint, where the caret sits, and the toolbar state — everything the Swift side needs for one repaint, in one value. Returned by every view-producing method.

Fields§

§rows: Vec<Row>§tables: Vec<TableView>

Tables described structurally, for a frontend that draws its own grid instead of painting the box-glyph rows. Empty in the source view. Each names the rows span its picture occupies, to be skipped.

§directives: Vec<DirectiveView>

Leaf directives (::name{…}) described structurally, for a frontend that paints what the host app’s vocabulary makes of them instead of the placeholder row. Empty in the source view, where the directive is the literal text the caret is editing.

§media: Vec<MediaView>

Block-level images, videos, and audio described structurally, for a frontend that lays real views over the rows core reserved instead of painting the placeholder glyphs. Empty in the source view, where the ![](…) or <video> markup is the literal text being edited.

§caret_row: u32

The caret’s row: an index into Self::rows.

§caret_col: u32

The caret’s display column within its row — core’s grid position. Kept for callers reasoning in columns; a proportional renderer wants Self::caret_ch instead.

§caret_ch: u32

The caret’s offset within its row’s text in UTF-16 code units — what NSAttributedString/NSTextView count to. This is caret_col mapped through the row’s grapheme widths, so it lands the caret correctly past wide glyphs (CJK, emoji) where a column and a character index diverge.

§caret_src: u32

The caret’s source byte offset — the coordinate a table cell is keyed by (TableCellView::start/end), so a frontend drawing its own grid can find which cell the caret sits in without the picture-row indices.

§has_selection: bool

Whether a (non-empty) selection is active.

§anchor_row: u32

The selection’s fixed end (the caret is the moving end), as a row and a UTF-16 offset — so the renderer can restore a native selection with the same direction the model has. Equal to the caret when has_selection is false.

§anchor_ch: u32§dirty: bool

Whether the buffer differs from the last saved bytes — for a “● modified” affordance.

§view: String

"wysiwyg" or "source", for a view-toggle affordance.

§heading: Option<u32>

The heading level at the caret, if any — a toolbar lights H1…H6 from it.

§active: Vec<String>

The inline marks active at the caret (bold, italic, code, …) — the toolbar lights the matching buttons.

§link: Option<String>

The destination of the link the caret stands in, or None — the toolbar lights its Link button from it and seeds an edit of that link with it.

It rides the frame rather than being a query a toolbar makes for itself because a toolbar only redraws when the state changes: walking the caret out of a link changes no mark, no heading, and no dirty flag, so a Link button reading this by a call of its own would keep a stale light on. Same reason heading is here and not asked for.

Only a parsed link answers (LeafDoc::link_destination_at_caret); a wikilink is literal text with no node behind it, and has nothing to repoint — see LinkTarget.swift.

Trait Implementations§

Source§

impl<UT> ConvertError<UT> for DocView

Source§

impl<UT> FfiConverter<UT> for DocView

Source§

const TYPE_ID_META: MetadataBuffer

Type ID metadata, serialized into a MetadataBuffer.
Source§

type FfiType = RustBuffer

The low-level type used for passing values of this type over the FFI. Read more
Source§

fn lower(v: Self) -> RustBuffer

Lower a rust value of the target type, into an FFI value of type Self::FfiType. Read more
Source§

fn try_lift(buf: RustBuffer) -> Result<Self>

Lift a rust value of the target type, from an FFI value of type Self::FfiType. Read more
Source§

fn write(obj: Self, buf: &mut Vec<u8>)

Write a rust value into a buffer, to send over the FFI in serialized form. Read more
Source§

fn try_read(buf: &mut &[u8]) -> Result<Self>

Read a rust value from a buffer, received over the FFI in serialized form. Read more
Source§

impl<UT> Lift<UT> for DocView

Source§

type FfiType = <DocView as FfiConverter<UT>>::FfiType

Source§

fn try_lift(v: Self::FfiType) -> Result<Self>

Source§

fn try_read(buf: &mut &[u8]) -> Result<Self>

Source§

fn try_lift_from_rust_buffer(v: RustBuffer) -> Result<Self, Error>

Convenience method
Source§

impl<UT> LiftRef<UT> for DocView

Source§

impl<UT> LiftReturn<UT> for DocView

Source§

type ReturnType = <DocView as Lift<UT>>::FfiType

FFI return type for trait interfaces
Source§

fn try_lift_successful_return(v: Self::ReturnType) -> Result<Self>

Lift a successfully returned value from a trait interface
Source§

fn lift_foreign_return( ffi_return: Self::ReturnType, call_status: RustCallStatus, ) -> Self

Lift a foreign returned value from a trait interface Read more
Source§

fn lift_error(_buf: RustBuffer) -> Self

Lift a Rust value for a callback interface method error result Read more
Source§

fn handle_callback_unexpected_error(e: UnexpectedUniFFICallbackError) -> Self

Lift a Rust value for an unexpected callback interface error Read more
Source§

impl<UT> Lower<UT> for DocView

Source§

type FfiType = <DocView as FfiConverter<UT>>::FfiType

Source§

fn lower(obj: Self) -> Self::FfiType

Source§

fn write(obj: Self, buf: &mut Vec<u8>)

Source§

fn lower_into_rust_buffer(obj: Self) -> RustBuffer

Convenience method
Source§

impl<UT> LowerError<UT> for DocView

Source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
Source§

impl<UT> LowerReturn<UT> for DocView

Source§

type ReturnType = <DocView as Lower<UT>>::FfiType

The type that should be returned by scaffolding functions for this type. Read more
Source§

fn lower_return(v: Self) -> Result<Self::ReturnType, RustCallError>

Lower the return value from an scaffolding call Read more
Source§

fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>

Lower the return value for failed argument lifts Read more
Source§

impl<UT> TypeId<UT> for DocView

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, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. 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, 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.