pub struct EditorState { /* private fields */ }Expand description
The editor state. Keep one per editor in your application.
Implementations§
Source§impl EditorState
impl EditorState
Sourcepub fn with_markdown(markdown_text: &str) -> Self
pub fn with_markdown(markdown_text: &str) -> Self
A document parsed from CommonMark (with the GFM extensions
strikethrough, task lists and tables; see Self::features).
Sourcepub fn style(self, style: EditorStyle) -> Self
pub fn style(self, style: EditorStyle) -> Self
Builder: sets the style.
Sourcepub fn zoom_settings(self, settings: ZoomSettings) -> Self
pub fn zoom_settings(self, settings: ZoomSettings) -> Self
Builder: sets the zoom settings.
Sourcepub fn tab_width(self, spaces: usize) -> Self
pub fn tab_width(self, spaces: usize) -> Self
Builder: number of spaces the Tab key inserts (0 = Tab not handled).
Sourcepub fn highlighter(self, highlighter: impl CodeHighlighter) -> Self
pub fn highlighter(self, highlighter: impl CodeHighlighter) -> Self
Builder: installs a code highlighting plugin.
Sourcepub fn features(self, features: Features) -> Self
pub fn features(self, features: Features) -> Self
Builder: enables or disables optional Markdown features. The document is read again with the new features.
Sourcepub fn language(self, language: Language) -> Self
pub fn language(self, language: Language) -> Self
Builder: sets the language of the toolbar, link bar and status bar.
Sourcepub fn block_renderer(self, renderer: impl BlockRenderer) -> Self
pub fn block_renderer(self, renderer: impl BlockRenderer) -> Self
Builder: adds a renderer for fenced code blocks of some languages. Call it once per renderer; the first one listing a language wins.
Sourcepub fn images(self, settings: ImageSettings) -> Self
pub fn images(self, settings: ImageSettings) -> Self
Builder: what happens with pasted, dropped and inserted images.
Sourcepub fn image_base(self, folder: impl Into<PathBuf>) -> Self
pub fn image_base(self, folder: impl Into<PathBuf>) -> Self
Builder: folder for relative image URLs (desktop display).
Sourcepub fn image_loader(
self,
loader: impl Fn(&str) -> Option<Vec<u8>> + Send + Sync + 'static,
) -> Self
pub fn image_loader( self, loader: impl Fn(&str) -> Option<Vec<u8>> + Send + Sync + 'static, ) -> Self
Builder: loads image bytes for display by URL.
Sourcepub fn markdown(&self) -> String
pub fn markdown(&self) -> String
The document as Markdown, without image placeholders and with full
data: URLs. Builds the whole text: call it on changes, not in view.
Sourcepub fn plain_text(&self) -> String
pub fn plain_text(&self) -> String
The document as plain text.
Sourcepub fn selected_text(&self) -> Option<String>
pub fn selected_text(&self) -> Option<String>
The selected text, if any.
pub fn word_count(&self) -> usize
pub fn current_mode(&self) -> Mode
pub fn current_style(&self) -> &EditorStyle
pub fn current_paper(&self) -> &Paper
Sourcepub fn current_zoom(&self) -> f32
pub fn current_zoom(&self) -> f32
Current zoom factor (1.0 = 100 %).
pub fn current_zoom_settings(&self) -> &ZoomSettings
Sourcepub fn current_tab_width(&self) -> usize
pub fn current_tab_width(&self) -> usize
Spaces per Tab (0 = Tab not handled).
pub fn current_image_settings(&self) -> &ImageSettings
Sourcepub fn pending_images(&self) -> usize
pub fn pending_images(&self) -> usize
Images handed to the application and not answered yet.
pub fn has_highlighter(&self) -> bool
pub fn current_features(&self) -> Features
pub fn current_language(&self) -> Language
Sourcepub fn rendered_languages(&self) -> Vec<String>
pub fn rendered_languages(&self) -> Vec<String>
Languages drawn by block renderers.
Sourcepub fn code_languages(&self) -> Vec<String>
pub fn code_languages(&self) -> Vec<String>
Languages offered for code blocks: from the highlighter (or a common list) and the block renderers.
Sourcepub fn task_progress(&self) -> (usize, usize)
pub fn task_progress(&self) -> (usize, usize)
(checked, total) task list items.
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Number of pages (1 in full-width mode).
Sourcepub fn current_page(&self) -> usize
pub fn current_page(&self) -> usize
Page (1-based) that contains the caret.
pub fn is_focused(&self) -> bool
pub fn can_undo(&self) -> bool
pub fn can_redo(&self) -> bool
Sourcepub fn formatting(&self) -> Formatting
pub fn formatting(&self) -> Formatting
Formatting at the caret (or at the start of the selection).
Sourcepub fn set_markdown(&mut self, markdown_text: &str)
pub fn set_markdown(&mut self, markdown_text: &str)
Replaces the whole document. Clears history, pending images and the dirty flag.
Sourcepub fn mark_saved(&mut self)
pub fn mark_saved(&mut self)
Clears the dirty flag (call after saving).
pub fn set_style(&mut self, style: EditorStyle)
pub fn set_paper(&mut self, paper: Paper)
pub fn set_zoom_settings(&mut self, settings: ZoomSettings)
Sourcepub fn set_zoom(&mut self, zoom: f32)
pub fn set_zoom(&mut self, zoom: f32)
Sets the zoom factor (1.0 = 100 %), also when zoom is disabled.
Sourcepub fn set_tab_width(&mut self, spaces: usize)
pub fn set_tab_width(&mut self, spaces: usize)
Spaces per Tab; 0 leaves Tab to the application.
pub fn set_highlighter(&mut self, highlighter: Option<Arc<dyn CodeHighlighter>>)
Sourcepub fn set_language(&mut self, language: Language)
pub fn set_language(&mut self, language: Language)
Sets the language of the toolbar, link bar and status bar. The document is not changed.
Sourcepub fn set_features(&mut self, features: Features)
pub fn set_features(&mut self, features: Features)
Enables or disables optional Markdown features. In WYSIWYG mode the document is read again, as if it had been loaded with the new features; the undo history starts again.
Sourcepub fn set_block_renderers(&mut self, renderers: Vec<Arc<dyn BlockRenderer>>)
pub fn set_block_renderers(&mut self, renderers: Vec<Arc<dyn BlockRenderer>>)
Replaces the block renderers. The first renderer listing a language draws it.
pub fn set_image_settings(&mut self, settings: ImageSettings)
pub fn set_image_base(&mut self, folder: Option<PathBuf>)
pub fn set_image_loader(&mut self, loader: Option<ImageLoader>)
Sourcepub fn reload_images(&mut self)
pub fn reload_images(&mut self)
Forgets loaded images and loads them again.
Sourcepub fn set_mode(&mut self, mode: Mode)
pub fn set_mode(&mut self, mode: Mode)
Switches between WYSIWYG and source mode. The undo history starts again after a switch.
Sourcepub fn execute(&mut self, command: Command) -> Output
pub fn execute(&mut self, command: Command) -> Output
Runs a command and reports what happened.
Sourcepub fn subscription(&self) -> Subscription<Action>
pub fn subscription(&self) -> Subscription<Action>
Caret blinking and dropped image files:
state.subscription().map(Message::Editor).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EditorState
impl !RefUnwindSafe for EditorState
impl !Sync for EditorState
impl !UnwindSafe for EditorState
impl Forget for EditorState
impl Send for EditorState
impl Unpin for EditorState
impl UnsafeUnpin for EditorState
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.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<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.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 moreimpl<T> MaybeClone for T
impl<T> MaybeDebug for T
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().