Struct Editor
pub struct Editor {
pub expr: MathExpr,
pub caret: Path,
pub anchor: Option<usize>,
}Expand description
The full editor state for one field.
Fields§
§expr: MathExpr§caret: Path§anchor: Option<usize>When set, the selection anchor (same row as the caret).
Implementations§
§impl Editor
impl Editor
pub fn new(expr: MathExpr) -> Editor
pub fn from_linear(s: &str) -> Editor
pub fn to_linear(&self) -> String
pub fn selection(&self) -> Option<Sel>
pub fn selection(&self) -> Option<Sel>
Current selection as a single-row range, if any non-empty selection.
pub fn move_left(&mut self, extend: bool)
pub fn move_left(&mut self, extend: bool)
Move left one atom. Steps out of / into structures GeoGebra-style.
pub fn move_right(&mut self, extend: bool)
pub fn move_right(&mut self, extend: bool)
Move right one atom.
pub fn move_up(&mut self)
pub fn move_up(&mut self)
Up: move to a higher sibling box (denominator→numerator, into exponent).
pub fn move_down(&mut self)
pub fn move_down(&mut self)
Down: move to a lower sibling box (numerator→denominator).
pub fn home(&mut self, extend: bool)
pub fn end(&mut self, extend: bool)
pub fn move_word_left(&mut self, extend: bool)
pub fn move_word_left(&mut self, extend: bool)
Ctrl+Left: jump to the start of the word/number/identifier to the left.
pub fn move_word_right(&mut self, extend: bool)
pub fn move_word_right(&mut self, extend: bool)
Ctrl+Right: jump to the end of the word/number to the right.
pub fn select_all(&mut self)
pub fn select_token_at(&mut self, steps: Vec<(usize, Slot)>, index: usize)
pub fn select_token_at(&mut self, steps: Vec<(usize, Slot)>, index: usize)
Select the token (number / identifier run / single structure) under
index — used for double-click.
pub fn backspace(&mut self)
pub fn backspace(&mut self)
Backspace: delete selection, else the atom before the caret. At the
front of a structure’s box, unwrap that structure (GeoGebra style).
pub fn delete(&mut self)
pub fn delete(&mut self)
Delete (forward): delete selection, else the atom after the caret. At the end of a child box, also unwrap the parent structure forward.
pub fn delete_selection(&mut self) -> bool
pub fn delete_selection(&mut self) -> bool
Delete the active selection if any; returns whether it did.
pub fn insert_char(&mut self, ch: char)
pub fn insert_char(&mut self, ch: char)
Insert a literal character (digit, letter, ., operator).
pub fn type_char(&mut self, ch: char)
pub fn type_char(&mut self, ch: char)
Type one logical character with GeoGebra-style structured building.
pub fn insert_sqrt(&mut self)
pub fn insert_sqrt(&mut self)
Build an empty radical at the caret and drop into its radicand — the
structured equivalent of typing sqrt(. This backs the √ glyph as
entered input (routed here by type_char), so a √ from the keyboard
/ an IME / a paste builds a real radical rather than a literal character
the engine can’t parse.
pub fn selected_linear(&self) -> Option<String>
pub fn selected_linear(&self) -> Option<String>
The selected sub-row serialized to a linear string (for copy/cut).
pub fn paste_linear(&mut self, s: &str)
pub fn paste_linear(&mut self, s: &str)
Paste a linear string at the caret (replacing any selection), parsed back into structured nodes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Editor
impl RefUnwindSafe for Editor
impl Send for Editor
impl Sync for Editor
impl Unpin for Editor
impl UnsafeUnpin for Editor
impl UnwindSafe for Editor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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