pub struct MathEditor { /* private fields */ }Expand description
A structural math editor view: the model, the caret, the cached raster, an in-progress
\command buffer with autocomplete, and the draggable palette’s position.
Implementations§
Source§impl MathEditor
impl MathEditor
pub fn new(cx: &mut Context<'_, Self>) -> Self
Sourcepub fn from_latex(
latex: &str,
font_size: f32,
at_end: bool,
align: MathAlign,
theme: MathTheme,
cx: &mut Context<'_, Self>,
) -> Self
pub fn from_latex( latex: &str, font_size: f32, at_end: bool, align: MathAlign, theme: MathTheme, cx: &mut Context<'_, Self>, ) -> Self
Build an editor seeded with the formula parsed from latex, rendered at font_size
px/em — for editing an existing $$…$$ block in-line at its displayed size. The caret
lands at the end of the top row when at_end, else at the start — so arrowing into
the block from below/right enters at the end, and from above/left enters at the start.
align matches the display block’s justification so entering edit doesn’t shift it.
Sourcepub fn to_latex(&self) -> String
pub fn to_latex(&self) -> String
The current formula as LaTeX, to write back into the $$…$$ block.
Sourcepub fn align(&self) -> MathAlign
pub fn align(&self) -> MathAlign
The current horizontal alignment, so the host writes the matching marker on commit.
Sourcepub fn set_align(&mut self, align: MathAlign, cx: &mut Context<'_, Self>)
pub fn set_align(&mut self, align: MathAlign, cx: &mut Context<'_, Self>)
Re-justify the in-line formula (from the right-click “Align” menu) — immediate visual feedback; the host persists the marker on commit.
Sourcepub fn focus_handle(&self) -> FocusHandle
pub fn focus_handle(&self) -> FocusHandle
The focus handle, so the host can focus the editor on open.
Trait Implementations§
Source§impl Render for MathEditor
impl Render for MathEditor
Auto Trait Implementations§
impl !RefUnwindSafe for MathEditor
impl !Send for MathEditor
impl !Sync for MathEditor
impl !UnwindSafe for MathEditor
impl Freeze for MathEditor
impl Unpin for MathEditor
impl UnsafeUnpin for MathEditor
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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