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
impl Editor
Sourcepub fn from_document(doc: &Document) -> Result<Self, DocumentError>
pub fn from_document(doc: &Document) -> Result<Self, DocumentError>
An editor holding doc, which must pass Document::validate, see Document::repair.
Sourcepub fn revision(&self) -> u64
pub fn revision(&self) -> u64
Advances on every content change and on Editor::restore, never on motion.
Sourcepub fn cursor(&self) -> CaretPath
pub fn cursor(&self) -> CaretPath
The caret, which is the selection focus while a selection is active.
Sourcepub fn set_cursor(&mut self, at: &CaretPath) -> Result<(), PathError>
pub fn set_cursor(&mut self, at: &CaretPath) -> Result<(), PathError>
Place the caret, collapsing the selection and closing the menu.
Sourcepub fn selection(&self) -> Option<Selection>
pub fn selection(&self) -> Option<Selection>
The active selection, None when the caret is collapsed.
Sourcepub fn set_selection(
&mut self,
anchor: &CaretPath,
focus: &CaretPath,
) -> Result<(), PathError>
pub fn set_selection( &mut self, anchor: &CaretPath, focus: &CaretPath, ) -> Result<(), PathError>
Select between two carets in the same sequence and close the menu.
Sourcepub fn at_slot_start(&self) -> bool
pub fn at_slot_start(&self) -> bool
Whether the caret is at the start of its slot.
Sourcepub fn at_slot_end(&self) -> bool
pub fn at_slot_end(&self) -> bool
Whether the caret is at the end of its slot.
Sourcepub fn in_text_slot(&self) -> bool
pub fn in_text_slot(&self) -> bool
Whether the caret is inside \text{}.
The open swap or delete menu.
Sourcepub fn matrix_shape(&self) -> Option<(usize, usize)>
pub fn matrix_shape(&self) -> Option<(usize, usize)>
Rows and columns of the matrix whose cell holds the caret.
Sourcepub fn input_context(&self) -> InputContext
pub fn input_context(&self) -> InputContext
Everything a keymap needs to know about the caret in one call.
Sourcepub fn set_host_box_policy(&mut self, policy: HostBoxPolicy)
pub fn set_host_box_policy(&mut self, policy: HostBoxPolicy)
Choose whether horizontal motion steps over host boxes or stops and reports them.
Sourcepub fn place_at(&mut self, edge: Edge)
pub fn place_at(&mut self, edge: Edge)
Put the caret at an edge of the formula, clearing selection and menu.
Sourcepub fn source(&self) -> Source
pub fn source(&self) -> Source
LaTeX for typesetting, with \phantom{x} boxes in empty slots so they can be drawn.
Sourcepub fn display_source(&self) -> 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.
Sourcepub fn render(
&self,
source: &Source,
fragment: &Fragment,
) -> Result<RenderOutput, StaleSource>
pub fn render( &self, source: &Source, fragment: &Fragment, ) -> Result<RenderOutput, StaleSource>
Geometry for the caret, selection, placeholders, menu, and host boxes over fragment.
Sourcepub fn hit_test(
&self,
source: &Source,
fragment: &Fragment,
at: Point,
) -> Result<Option<CaretPath>, StaleSource>
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.
Sourcepub fn restore(&mut self, s: &Snapshot) -> Result<(), RestoreError>
pub fn restore(&mut self, s: &Snapshot) -> Result<(), RestoreError>
Return to a snapshot, closing the menu and advancing the revision, unchanged on error.
Sourcepub fn selection_document(&self) -> Option<Document>
pub fn selection_document(&self) -> Option<Document>
The selected nodes as a standalone document for the clipboard.
Sourcepub fn selection_tex(&self) -> Option<String>
pub fn selection_tex(&self) -> Option<String>
The selection as clean LaTeX for external clipboards.