[][src]Struct termimad::FmtComposite

pub struct FmtComposite<'s> {
    pub composite: Composite<'s>,
    pub visible_length: usize,
    pub spacing: Option<Spacing>,
}

Wrap a Minimad Composite, which is a list of Compounds (which are strings with an homogeneous style)

Fields

composite: Composite<'s>visible_length: usizespacing: Option<Spacing>

Methods

impl<'s> FmtComposite<'s>[src]

pub fn new() -> Self[src]

pub fn from(composite: Composite<'s>, skin: &MadSkin) -> Self[src]

pub fn completions(&self) -> (usize, usize)[src]

Return the number of characters (usually spaces) to insert both sides of the composite

pub fn add_compound(&mut self, compound: Compound<'s>)[src]

Add a compound and modifies visible_length accordingly

pub fn recompute_width(&mut self, skin: &MadSkin)[src]

Ensure the cached visible_length is correct.

It's normally not necessary to call it, but this must be called if compounds are added, removed or modified without using the FmtComposite API

pub fn fit_width(&mut self, width: usize, align: Alignment, skin: &MadSkin)[src]

try to ensure the composite's width doesn't exceed the given width.

The alignment can be used, if necessary, to know which side it's better to remove content (for example if the alignment is left then we remove at right). The fitter may remove a part in the core of the composite if it looks good enough. In this specific case an ellipsis will replace the removed part.

pub fn extend_width(&mut self, width: usize, align: Alignment)[src]

if the composite is smaller than the given width, pad it according to the alignment.

pub fn fill_width(&mut self, width: usize, align: Alignment, skin: &MadSkin)[src]

try to make it so that the composite has exactly the given width, either by shortening it or by adding space.

This calls the fit_width and extend_width methods.

Trait Implementations

impl<'s> Clone for FmtComposite<'s>[src]

impl<'s> Debug for FmtComposite<'s>[src]

impl<'_> Default for FmtComposite<'_>[src]

Auto Trait Implementations

impl<'s> RefUnwindSafe for FmtComposite<'s>

impl<'s> Send for FmtComposite<'s>

impl<'s> Sync for FmtComposite<'s>

impl<'s> Unpin for FmtComposite<'s>

impl<'s> UnwindSafe for FmtComposite<'s>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.