pub struct RichDoc {
pub font: String,
pub size: u16,
/* private fields */
}Expand description
the document of ui.richtext (see the module header)
Fields§
§font: Stringthe document’s font family (“”: the UI font)
size: u16the document’s size in tenths of a point (0: 11 pt)
Implementations§
Source§impl RichDoc
impl RichDoc
Sourcepub fn from_paras(paras: Vec<Para>) -> RichDoc
pub fn from_paras(paras: Vec<Para>) -> RichDoc
paragraphs (an empty list: one empty paragraph); the caret at the start
Sourcepub fn from_plain(s: &str) -> RichDoc
pub fn from_plain(s: &str) -> RichDoc
unformatted text: a paragraph per line
Sourcepub fn para_count(&self) -> usize
pub fn para_count(&self) -> usize
the number of paragraphs (at least 1)
Sourcepub fn revision(&self) -> u64
pub fn revision(&self) -> u64
counts the changes of the content (edits, undo, redo; not the selection)
Sourcepub fn set_selection(&mut self, sel: TextSel)
pub fn set_selection(&mut self, sel: TextSel)
move the selection (clamped to the text, not undoable)
Sourcepub fn text_range(&self, a: TextPos, b: TextPos) -> String
pub fn text_range(&self, a: TextPos, b: TextPos) -> String
the text between a and b (paragraphs joined by ‘\n’)
Sourcepub fn paras_range(&self, a: TextPos, b: TextPos) -> Vec<Para>
pub fn paras_range(&self, a: TextPos, b: TextPos) -> Vec<Para>
the paragraphs between a and b (the first and the last cut there), with attributes
Sourcepub fn selected_text(&self) -> String
pub fn selected_text(&self) -> String
the selected text
Sourcepub fn selected_paras(&self) -> Vec<Para>
pub fn selected_paras(&self) -> Vec<Para>
the selected paragraphs (a fragment for the clipboard)
Sourcepub fn current_para(&self) -> &Para
pub fn current_para(&self) -> &Para
the paragraph with the caret
Sourcepub fn current_fmt(&self) -> Fmt
pub fn current_fmt(&self) -> Fmt
the format typing takes now (a format chosen without a selection, else the text’s at the caret); with a selection: its first character’s, the flags all of it has
Sourcepub fn undo_label(&self) -> Option<&str>
pub fn undo_label(&self) -> Option<&str>
the label of the step undo takes back (“Fett”, “Schreiben” …)
Sourcepub fn redo_label(&self) -> Option<&str>
pub fn redo_label(&self) -> Option<&str>
the label of the step redo does again
Sourcepub fn mark_saved(&mut self)
pub fn mark_saved(&mut self)
the content is saved now (is_dirty false until the next change)
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
forget the undo steps
Sourcepub fn group_begin(&mut self, label: &str)
pub fn group_begin(&mut self, label: &str)
the next edits are one undo step (until group_end)
Sourcepub fn insert_text(&mut self, s: &str) -> bool
pub fn insert_text(&mut self, s: &str) -> bool
replace the selection by text (a paragraph per line) in the current format
Sourcepub fn insert_paras(&mut self, frag: &[Para]) -> bool
pub fn insert_paras(&mut self, frag: &[Para]) -> bool
replace the selection by paragraphs (a paste): several keep their attributes, one is inserted into the paragraph at the caret
Sourcepub fn delete_selection(&mut self) -> bool
pub fn delete_selection(&mut self) -> bool
remove the selection
Sourcepub fn split(&mut self) -> bool
pub fn split(&mut self) -> bool
Enter: split the paragraph at the caret (the selection is replaced). In an empty list item the list ends instead (a nested one moves out a level); after a heading the new paragraph is body text.
Sourcepub fn toggle(&mut self, flag: u8) -> bool
pub fn toggle(&mut self, flag: u8) -> bool
RF_BOLD / RF_ITALIC / RF_UNDER / RF_STRIKE on (when not all of the selection has it) or off
Sourcepub fn set_size(&mut self, tenths: u16) -> bool
pub fn set_size(&mut self, tenths: u16) -> bool
the size in tenths of a point (0: the document’s)
Sourcepub fn set_link(&mut self, url: &str) -> bool
pub fn set_link(&mut self, url: &str) -> bool
a link on the selection (without one: on the link at the caret); “” removes it. A collapsed caret outside a link inserts the url as linked text.
Sourcepub fn clear_format(&mut self) -> bool
pub fn clear_format(&mut self) -> bool
back to the default format (links stay)
Sourcepub fn toggle_list(&mut self, kind: u8) -> bool
pub fn toggle_list(&mut self, kind: u8) -> bool
LS_BULLET / LS_NUMBER: the selected paragraphs become such list items, or plain paragraphs when all of them already are
Sourcepub fn indent(&mut self, delta: i32) -> bool
pub fn indent(&mut self, delta: i32) -> bool
one level deeper (delta 1) or out (-1), 0..LEVEL_MAX
Sourcepub fn set_paras(&mut self, paras: Vec<Para>) -> bool
pub fn set_paras(&mut self, paras: Vec<Para>) -> bool
replace the whole content (one undo step)