Struct termimad::MadView

source ·
pub struct MadView {
    pub skin: MadSkin,
    pub scroll: usize,
    /* private fields */
}
Expand description

A MadView is like a textview but it owns everything, from the source markdown to the area and the skin, which often makes it more convenient for dynamic texts. It’s also resizeable.

Fields§

§skin: MadSkin§scroll: usize

Implementations§

source§

impl MadView

source

pub const fn from(markdown: String, area: Area, skin: MadSkin) -> MadView

make a displayed text, that is a text in an area

source

pub fn write(&self) -> Result<(), Error>

render the markdown in the area, taking the scroll into account

source

pub fn write_on<W: Write>(&self, w: &mut W) -> Result<(), Error>

source

pub fn resize(&mut self, area: &Area)

sets the new area. If it’s the same as the precedent one, this operation does nothing. The scroll is kept if possible.

source

pub fn try_scroll_lines(&mut self, lines_count: i32)

set the scroll amount. lines_count can be negative

source

pub fn try_scroll_pages(&mut self, pages_count: i32)

set the scroll amount. lines_count can be negative

source

pub fn apply_key_combination<K: Into<KeyCombination>>(&mut self, key: K) -> bool

Apply an event being a key: page_up, page_down, up and down.

Return true when the event led to a change, false when it was discarded.

It’s possible to handle the key yourself and call the try_scroll methods.

source

pub fn apply_key_event(&mut self, key: KeyEvent) -> bool

Apply an event being a key: page_up, page_down, up and down.

Return true when the event led to a change, false when it was discarded.

It’s possible to handle the key yourself and call the try_scroll methods.

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> 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.