Skip to main content

Tree

Struct Tree 

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

The editable math tree.

Implementations§

Source§

impl Tree

Source

pub fn to_doc(&self) -> Document

Serialize the live tree to the id free document form.

Source

pub fn from_doc(doc: &Document) -> Self

Rebuild a tree from the document form with fresh ids.

Source

pub fn insert_fragment(&mut self, at: Cursor, frag: &DocFragment) -> Cursor

Splice a clipboard fragment into at.seq starting at at.index.

Source§

impl Tree

Source

pub fn export_latex(&self) -> (String, SpanMap)

Exports the whole document to rendering LaTeX and records spans for placeholder matching.

Source

pub fn export_display(&self) -> String

Exports the whole document to clean display and copy LaTeX.

Source

pub fn selection_latex(&self, sel: Selection) -> String

Exports a selection’s content to clean LaTeX for the host clipboard.

Source§

impl Tree

Source

pub fn new() -> Self

A new tree with an empty root sequence.

Source

pub fn root(&self) -> SeqId

Return the root sequence id.

Source

pub fn node(&self, id: NodeId) -> Option<&Node>

Return a node by id.

Source

pub fn seq(&self, id: SeqId) -> Option<&Seq>

Return a sequence by id.

Source

pub fn kind(&self, id: NodeId) -> Option<&Kind>

Return a node payload by id.

Source

pub fn items(&self, id: SeqId) -> &[NodeId]

Return the node ids stored in a sequence.

Source

pub fn len(&self, id: SeqId) -> usize

Return the number of nodes in a sequence.

Source

pub fn is_empty(&self, id: SeqId) -> bool

An empty sequence is a structural placeholder.

Source

pub fn seq_parent(&self, id: SeqId) -> Option<NodeId>

The node that owns this sequence as a slot, or None for the root.

Source

pub fn index_in_parent(&self, node: NodeId) -> Option<(SeqId, usize)>

The sequence and index where this node currently lives.

Source

pub fn child_seqs(&self, node: NodeId) -> Vec<SeqId>

All present slot sequences of a node in canonical navigation and ownership order.

Source§

impl Tree

Source

pub fn insert_atom(&mut self, at: Cursor, sym: Symbol) -> Cursor

Inserts an atom and returns the cursor after it.

Source

pub fn insert_fraction( &mut self, at: Cursor, style: FracStyle, sel: Option<Selection>, ) -> Cursor

Inserts a fraction and returns a cursor in the numerator or denominator.

Source

pub fn insert_sqrt(&mut self, at: Cursor, sel: Option<Selection>) -> Cursor

Inserts a radical and returns a cursor in the radicand.

Source

pub fn insert_delimiters( &mut self, at: Cursor, open: char, close: char, sel: Option<Selection>, ) -> Cursor

Inserts delimiters and returns a cursor in their body.

Source

pub fn insert_accent( &mut self, at: Cursor, mark: Mark, sel: Option<Selection>, ) -> Cursor

Inserts an accent and returns a cursor in its base.

Source

pub fn insert_styled( &mut self, at: Cursor, variant: Variant, sel: Option<Selection>, ) -> Cursor

Inserts a styled wrapper and returns a cursor in its content.

Source

pub fn insert_under_over( &mut self, at: Cursor, spec: UnderOverSpec, sel: Option<Selection>, ) -> Cursor

Inserts an under or over structure and returns a cursor in its base.

Source

pub fn insert_matrix( &mut self, at: Cursor, env: MatrixEnv, rows: usize, cols: usize, ) -> Cursor

Inserts a matrix and returns a cursor in the first cell.

Source

pub fn insert_big_op(&mut self, at: Cursor, op: Symbol) -> Cursor

Inserts a big operator with empty limits and returns a cursor after it.

Source

pub fn bigop_limit_target( &self, at: Cursor, which: ScriptSlot, ) -> Option<Cursor>

Returns the BigOp limit targeted by _ or ^ when the cursor is after the operator.

Source

pub fn attach_script(&mut self, at: Cursor, which: ScriptSlot) -> Cursor

Attaches or moves into a subscript or superscript on the node before the cursor.

Source

pub fn delete_backward(&mut self, at: Cursor) -> Cursor

Deletes backward, escalating empty placeholders and otherwise moving left when no leaf is removed.

Source

pub fn delete_forward(&mut self, at: Cursor) -> Cursor

Deletes forward as the mirror of Tree::delete_backward.

Source

pub fn delete_selection(&mut self, sel: Selection) -> Cursor

Deletes a contiguous selection run within one seq.

Source

pub fn matrix_shape_at(&self, at: Cursor) -> Option<(usize, usize)>

Returns the shape of the matrix containing the cursor.

Source

pub fn matrix_insert_row(&mut self, at: Cursor, side: Side) -> Cursor

Inserts a matrix row before or after the current row.

Source

pub fn matrix_delete_row(&mut self, at: Cursor) -> Cursor

Deletes the current matrix row when more than one row remains.

Source

pub fn matrix_insert_col(&mut self, at: Cursor, side: Side) -> Cursor

Inserts a matrix column before or after the current column.

Source

pub fn matrix_delete_col(&mut self, at: Cursor) -> Cursor

Deletes the current matrix column when more than one column remains.

Source

pub fn swap_variants(&self, node: NodeId) -> Option<Vec<SwapVariant>>

Returns swap menu alternatives for node, excluding its current value.

Source

pub fn apply_swap(&mut self, node: NodeId, variant: &SwapVariant)

Applies a chosen alternative by changing only the named tag fields.

Trait Implementations§

Source§

impl Clone for Tree

Source§

fn clone(&self) -> Tree

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 Debug for Tree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Tree

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnsafeUnpin for Tree

§

impl UnwindSafe for Tree

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