Skip to main content

Editor

Struct Editor 

Source
pub struct Editor { /* private fields */ }
Expand description

A headless structural math editor that never typesets, keeps no history, and has no callbacks.

Implementations§

Source§

impl Editor

Source

pub fn new() -> Self

An empty editor.

Source

pub fn from_document(doc: &Document) -> Result<Self, DocumentError>

An editor holding doc, which must pass Document::validate, see Document::repair.

Source

pub fn document(&self) -> Document

The whole document.

Source

pub fn revision(&self) -> u64

Advances on every content change and on Editor::restore, never on motion.

Source

pub fn cursor(&self) -> CaretPath

The caret, which is the selection focus while a selection is active.

Source

pub fn set_cursor(&mut self, at: &CaretPath) -> Result<(), PathError>

Place the caret, collapsing the selection and closing the menu.

Source

pub fn selection(&self) -> Option<Selection>

The active selection, None when the caret is collapsed.

Source

pub fn set_selection( &mut self, anchor: &CaretPath, focus: &CaretPath, ) -> Result<(), PathError>

Select between two carets in the same sequence and close the menu.

Source

pub fn at_start(&self) -> bool

Whether the caret is before everything in the formula.

Source

pub fn at_end(&self) -> bool

Whether the caret is after everything in the formula.

Source

pub fn at_slot_start(&self) -> bool

Whether the caret is at the start of its slot.

Source

pub fn at_slot_end(&self) -> bool

Whether the caret is at the end of its slot.

Source

pub fn in_text_slot(&self) -> bool

Whether the caret is inside \text{}.

Source

pub fn menu(&self) -> Option<MenuView>

The open swap or delete menu.

Source

pub fn matrix_shape(&self) -> Option<(usize, usize)>

Rows and columns of the matrix whose cell holds the caret.

Source

pub fn input_context(&self) -> InputContext

Everything a keymap needs to know about the caret in one call.

Source

pub fn set_host_box_policy(&mut self, policy: HostBoxPolicy)

Choose whether horizontal motion steps over host boxes or stops and reports them.

Source

pub fn place_at(&mut self, edge: Edge)

Put the caret at an edge of the formula, clearing selection and menu.

Source

pub fn source(&self) -> Source

LaTeX for typesetting, with \phantom{x} boxes in empty slots so they can be drawn.

Source

pub fn display_source(&self) -> Source

Clean LaTeX with spans, so hosts can map a caret to a byte offset in what users see.

Source

pub fn render( &self, source: &Source, fragment: &Fragment, ) -> Result<RenderOutput, StaleSource>

Geometry for the caret, selection, placeholders, menu, and host boxes over fragment.

Source

pub fn hit_test( &self, source: &Source, fragment: &Fragment, at: Point, ) -> Result<Option<CaretPath>, StaleSource>

The caret nearest at, None when the fragment has no geometry to hit.

Source

pub fn snapshot(&self) -> Snapshot

The current state for a host undo stack.

Source

pub fn restore(&mut self, s: &Snapshot) -> Result<(), RestoreError>

Return to a snapshot, closing the menu and advancing the revision, unchanged on error.

Source

pub fn selection_document(&self) -> Option<Document>

The selected nodes as a standalone document for the clipboard.

Source

pub fn selection_tex(&self) -> Option<String>

The selection as clean LaTeX for external clipboards.

Source

pub fn exec(&mut self, cmd: Command) -> Outcome

Run one command and report what it did.

Trait Implementations§

Source§

impl Default for Editor

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.