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>
impl<L: FontLoader> Session<L>
Sourcepub fn new(typesetter: Typesetter<L>) -> Self
pub fn new(typesetter: Typesetter<L>) -> Self
An empty editor typeset in display style by typesetter.
Sourcepub fn load(&mut self, doc: Document) -> Vec<Repair>
pub fn load(&mut self, doc: Document) -> Vec<Repair>
Replace the document, repairing what Document::validate rejects, and clear the history.
Sourcepub fn editor(&self) -> &Editor
pub fn editor(&self) -> &Editor
The editor, for queries such as document, menu, and matrix_shape.
Sourcepub fn keymap_mut(&mut self) -> &mut Keymap
pub fn keymap_mut(&mut self) -> &mut Keymap
The keymap, for defining words and switching autocorrect.
Sourcepub fn typesetter(&self) -> &Typesetter<L>
pub fn typesetter(&self) -> &Typesetter<L>
The typesetter, whose font loader draws the faces a view’s glyph runs name.
Sourcepub fn set_undo_limit(&mut self, limit: usize)
pub fn set_undo_limit(&mut self, limit: usize)
Keep at most limit undo steps.
Sourcepub fn set_math_mode(&mut self, mode: MathMode)
pub fn set_math_mode(&mut self, mode: MathMode)
Typeset inline or in display style.
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 key(&mut self, input: &KeyInput) -> Update
pub fn key(&mut self, input: &KeyInput) -> Update
Feed a key event through the keymap, its commands form one undo step.
Sourcepub fn text(&mut self, s: &str) -> Update
pub fn text(&mut self, s: &str) -> Update
Feed committed text such as IME output, as if each character were typed.
Sourcepub fn pointer(&mut self, at: Point, extend: bool) -> Update
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.
Sourcepub fn command(&mut self, cmd: Command) -> Update
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.
Sourcepub fn commit_word(&mut self, word: &str) -> Update
pub fn commit_word(&mut self, word: &str) -> Update
Insert what a palette word inserts, as one undo step like typing it.
Sourcepub fn step_over_host_box(&mut self, entry: HostBoxEntry) -> Update
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.
Sourcepub fn copy(&mut self) -> Option<ClipboardData>
pub fn copy(&mut self) -> Option<ClipboardData>
Copy the selection to the internal clipboard and return it for the system clipboard.
Sourcepub fn cut(&mut self) -> Option<(ClipboardData, Update)>
pub fn cut(&mut self) -> Option<(ClipboardData, Update)>
Copy the selection, then delete it as one undo step.
Sourcepub fn paste_json(&mut self, json: &str) -> Result<Update, PasteError>
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.
Sourcepub fn paste_internal(&mut self) -> Result<Update, TokenError>
pub fn paste_internal(&mut self) -> Result<Update, TokenError>
Paste the internal clipboard, giving each host box a fresh token.
Sourcepub fn paste_text(&mut self, s: &str) -> Update
pub fn paste_text(&mut self, s: &str) -> Update
Paste plain text through the keymap, as one undo step.
Sourcepub fn insert_host_box(&mut self) -> Result<(u32, Update), TokenError>
pub fn insert_host_box(&mut self) -> Result<(u32, Update), TokenError>
Mint a token and insert a host box carrying it.
Sourcepub fn mint_host_token(&mut self) -> Result<u32, TokenError>
pub fn mint_host_token(&mut self) -> Result<u32, TokenError>
Mint a token for a host box the host inserts itself.
Sourcepub fn set_host_box_size(
&mut self,
token: u32,
width: Length,
height: Length,
depth: Length,
) -> Result<(), TokenError>
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.
Sourcepub fn set_host_boxes(&mut self, provider: Box<dyn HostBoxes>)
pub fn set_host_boxes(&mut self, provider: Box<dyn HostBoxes>)
Answer \hostbox for tokens without a size through provider.
Sourcepub fn host_boxes_changed(&mut self)
pub fn host_boxes_changed(&mut self)
Typeset again on the next view, after the provider’s boxes changed.
Sourcepub fn live_host_tokens(&mut self) -> BTreeSet<u32>
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.
Sourcepub fn view(&mut self) -> Result<&View, TypesetError>
pub fn view(&mut self) -> Result<&View, TypesetError>
The typeset document with its caret and selection geometry, typeset again only after a change.
Sourcepub fn preview_word(&mut self, word: &str) -> Option<Result<View, TypesetError>>
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.