Skip to main content

MdViewState

Struct MdViewState 

Source
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: String

where relative image paths start (“app://help/”; “” = as given)

§label: String

the name for screen readers (“” = “Dokument”)

§images: u8

where the images come from: MI_LOCAL (default), MI_ASK, MI_APP (see the module header)

Implementations§

Source§

impl MdViewState

Source

pub fn new() -> MdViewState

an empty document

Source

pub fn doc(&self) -> &MdDoc

the document shown

Source

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

Source

pub fn update(&mut self) -> bool

take the document’s changes now (MdDoc::update; the view does it every frame) -> there were changes

Source

pub fn set_markdown(&mut self, s: &str)

show Markdown (parsed now unless it is the text shown already)

Source

pub fn set_html(&mut self, s: &str)

show HTML (parsed now unless it is the text shown already)

Source

pub fn set_doc(&mut self, doc: MdDoc)

show a document

Source

pub fn selection(&self) -> TextSel

the selection (TextPos: block, byte of its text)

Source

pub fn set_selection(&mut self, sel: TextSel)

select a range (clamped to the document)

Source

pub fn select_all(&mut self)

select the whole document

Source

pub fn selected_text(&self) -> String

the selection as text (list markers, cells by tabs, images as their alt texts)

Source

pub fn selected_html(&self) -> String

the selection as HTML

Source

pub fn scroll_to_block(&mut self, i: usize)

show block i at the top

Source

pub fn scroll_to_end(&mut self)

show the end, also while the document grows (until the user scrolls away)

Source

pub fn first_visible(&self) -> (usize, i32)

the first visible block and how many px of it are above the view

the link focused with Tab (an index of doc().link_spots())

Source

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

Source

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.

Source

pub fn field_text(&self, i: usize) -> &str

field i’s text (text fields, text areas, hidden fields; “” for the other kinds)

Source

pub fn field_checked(&self, i: usize) -> bool

field i is checked (check boxes, radios)

Source

pub fn field_selected(&self, i: usize) -> i32

the option chosen in field i (drop-down lists; -1: none)

Source

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)

Source

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)

Source

pub fn set_field_selected(&mut self, i: usize, k: i32)

choose option k of field i (a drop-down list; -1: none)

Source

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)

Source

pub fn reset_form(&mut self, form: usize)

the fields of form form get their first values back

Source

pub fn focused_field(&self) -> Option<usize>

the field with the keyboard focus (an index of doc().fields())

Trait Implementations§

Source§

impl Default for MdViewState

Source§

fn default() -> MdViewState

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> ErasedDestructor for T
where T: 'static,

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.