Skip to main content

Session

Struct Session 

Source
pub struct Session<L: FontLoader> { /* private fields */ }
Expand description

An editor with keymap, typesetting, undo, clipboard, and host box tokens, driven by a few input calls.

Implementations§

Source§

impl<L: FontLoader> Session<L>

Source

pub fn new(typesetter: Typesetter<L>) -> Self

An empty editor typeset in display style by typesetter.

Source

pub fn load(&mut self, doc: Document) -> Vec<Repair>

Replace the document, repairing what Document::validate rejects, and clear the history.

Source

pub fn editor(&self) -> &Editor

The editor, for queries such as document, menu, and matrix_shape.

Source

pub fn keymap(&self) -> &Keymap

The keymap, for its palette entries.

Source

pub fn keymap_mut(&mut self) -> &mut Keymap

The keymap, for defining words and switching autocorrect.

Source

pub fn typesetter(&self) -> &Typesetter<L>

The typesetter, whose font loader draws the faces a view’s glyph runs name.

Source

pub fn history(&self) -> &UndoStack

The undo history.

Source

pub fn set_undo_limit(&mut self, limit: usize)

Keep at most limit undo steps.

Source

pub fn set_math_mode(&mut self, mode: MathMode)

Typeset inline or in display style.

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 key(&mut self, input: &KeyInput) -> Update

Feed a key event through the keymap, its commands form one undo step.

Source

pub fn text(&mut self, s: &str) -> Update

Feed committed text such as IME output, as if each character were typed.

Source

pub fn pointer(&mut self, at: Point, extend: bool) -> Update

Place the caret at at, or extend the selection to it, in the coordinates of View::render.

Source

pub fn command(&mut self, cmd: Command) -> Update

Run one host command, such as a toolbar button or a menu row, as its own undo step.

Source

pub fn commit_word(&mut self, word: &str) -> Update

Insert what a palette word inserts, as one undo step like typing it.

Source

pub fn step_over_host_box(&mut self, entry: HostBoxEntry) -> Update

Cross the host box a motion stopped at, when the host does not take the caret into it.

Source

pub fn undo(&mut self) -> Update

Undo the last step.

Source

pub fn redo(&mut self) -> Update

Redo the last undone step.

Source

pub fn copy(&mut self) -> Option<ClipboardData>

Copy the selection to the internal clipboard and return it for the system clipboard.

Source

pub fn cut(&mut self) -> Option<(ClipboardData, Update)>

Copy the selection, then delete it as one undo step.

Source

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

The internal clipboard.

Source

pub fn paste_json(&mut self, json: &str) -> Result<Update, PasteError>

Paste document JSON, giving each host box a fresh token and the size its old token had.

Source

pub fn paste_internal(&mut self) -> Result<Update, TokenError>

Paste the internal clipboard, giving each host box a fresh token.

Source

pub fn paste_text(&mut self, s: &str) -> Update

Paste plain text through the keymap, as one undo step.

Source

pub fn insert_host_box(&mut self) -> Result<(u32, Update), TokenError>

Mint a token and insert a host box carrying it.

Source

pub fn mint_host_token(&mut self) -> Result<u32, TokenError>

Mint a token for a host box the host inserts itself.

Source

pub fn set_host_box_size( &mut self, token: u32, width: Length, height: Length, depth: Length, ) -> Result<(), TokenError>

Lay out token as an empty box of this size, for hosts that draw the box content themselves.

Source

pub fn set_host_boxes(&mut self, provider: Box<dyn HostBoxes>)

Answer \hostbox for tokens without a size through provider.

Source

pub fn host_boxes_changed(&mut self)

Typeset again on the next view, after the provider’s boxes changed.

Source

pub fn live_host_tokens(&mut self) -> BTreeSet<u32>

Tokens the document, the history, or the clipboard reference, and drop the sizes of every other token.

Source

pub fn view(&mut self) -> Result<&View, TypesetError>

The typeset document with its caret and selection geometry, typeset again only after a change.

Source

pub fn preview_word(&mut self, word: &str) -> Option<Result<View, TypesetError>>

A standalone view of what a palette word inserts, None for an unknown word.

Trait Implementations§

Source§

impl<L: FontLoader> Debug for Session<L>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<L> !RefUnwindSafe for Session<L>

§

impl<L> !Send for Session<L>

§

impl<L> !Sync for Session<L>

§

impl<L> !UnwindSafe for Session<L>

§

impl<L> Freeze for Session<L>
where Typesetter<L>: Freeze,

§

impl<L> Unpin for Session<L>
where Typesetter<L>: Unpin,

§

impl<L> UnsafeUnpin for Session<L>

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.