pub struct MdViewState {
pub base: String,
pub label: String,
pub images: u8,
/* private fields */
}Expand description
the state of a document view (see the module header)
Fields§
§base: Stringwhere relative image paths start (“app://help/”; “” = as given)
label: Stringthe name for screen readers (“” = “Dokument”)
images: u8where the images come from: MI_LOCAL (default), MI_ASK, MI_APP (see the module header)
Implementations§
Source§impl MdViewState
impl MdViewState
Sourcepub fn new() -> MdViewState
pub fn new() -> MdViewState
an empty document
Sourcepub fn doc_mut(&mut self) -> &mut MdDoc
pub fn doc_mut(&mut self) -> &mut MdDoc
the document to change (an HTML document’s elements, md_dom.rs): the view takes the changes at its next frame (or update()) and keeps its place, selection, focus and the values the user gave the fields that stay
Sourcepub fn update(&mut self) -> bool
pub fn update(&mut self) -> bool
take the document’s changes now (MdDoc::update; the view does it every frame) -> there were changes
Sourcepub fn set_markdown(&mut self, s: &str)
pub fn set_markdown(&mut self, s: &str)
show Markdown (parsed now unless it is the text shown already)
Sourcepub fn set_selection(&mut self, sel: TextSel)
pub fn set_selection(&mut self, sel: TextSel)
select a range (clamped to the document)
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
select the whole document
Sourcepub fn selected_text(&self) -> String
pub fn selected_text(&self) -> String
the selection as text (list markers, cells by tabs, images as their alt texts)
Sourcepub fn selected_html(&self) -> String
pub fn selected_html(&self) -> String
the selection as HTML
Sourcepub fn scroll_to_block(&mut self, i: usize)
pub fn scroll_to_block(&mut self, i: usize)
show block i at the top
Sourcepub fn scroll_to_end(&mut self)
pub fn scroll_to_end(&mut self)
show the end, also while the document grows (until the user scrolls away)
Sourcepub fn first_visible(&self) -> (usize, i32)
pub fn first_visible(&self) -> (usize, i32)
the first visible block and how many px of it are above the view
Sourcepub fn focused_link(&self) -> Option<usize>
pub fn focused_link(&self) -> Option<usize>
the link focused with Tab (an index of doc().link_spots())
Sourcepub fn image_requests(&mut self) -> Vec<String>
pub fn image_requests(&mut self) -> Vec<String>
the image addresses the view waits for since the last call (MI_ASK / MI_APP; each one once): the app fetches them and answers with set_image
Sourcepub fn set_image(&mut self, addr: &str, data: Option<&[u8]>) -> bool
pub fn set_image(&mut self, addr: &str, data: Option<&[u8]>) -> bool
the bytes of an image address (None: it could not be had): decoded now, shown from the next frame on (the alt text when they are no picture) -> an image of the document waited for it. An address not asked yet is kept for the images that need it later.
Sourcepub fn field_text(&self, i: usize) -> &str
pub fn field_text(&self, i: usize) -> &str
field i’s text (text fields, text areas, hidden fields; “” for the other kinds)
Sourcepub fn field_checked(&self, i: usize) -> bool
pub fn field_checked(&self, i: usize) -> bool
field i is checked (check boxes, radios)
Sourcepub fn field_selected(&self, i: usize) -> i32
pub fn field_selected(&self, i: usize) -> i32
the option chosen in field i (drop-down lists; -1: none)
Sourcepub fn set_field_text(&mut self, i: usize, s: &str)
pub fn set_field_text(&mut self, i: usize, s: &str)
set field i’s text (text fields, text areas, hidden fields; changes of the document keep it, as the user’s input)
Sourcepub fn set_field_checked(&mut self, i: usize, on: bool)
pub fn set_field_checked(&mut self, i: usize, on: bool)
check field i or not (a radio: the others of its group go off)
Sourcepub fn set_field_selected(&mut self, i: usize, k: i32)
pub fn set_field_selected(&mut self, i: usize, k: i32)
choose option k of field i (a drop-down list; -1: none)
Sourcepub fn form_data(
&self,
form: usize,
button: Option<usize>,
) -> Vec<(String, String)>
pub fn form_data( &self, form: usize, button: Option<usize>, ) -> Vec<(String, String)>
the name / value pairs form form sends with the submit button button (as browsers
build them: fields with a name that are not disabled; check boxes and radios when
checked; a list’s chosen value; of the buttons only button)
Sourcepub fn reset_form(&mut self, form: usize)
pub fn reset_form(&mut self, form: usize)
the fields of form form get their first values back
Sourcepub fn focused_field(&self) -> Option<usize>
pub fn focused_field(&self) -> Option<usize>
the field with the keyboard focus (an index of doc().fields())