Struct termimad::FmtComposite
source · pub struct FmtComposite<'s> {
pub composite: Composite<'s>,
pub visible_length: usize,
pub spacing: Option<Spacing>,
}
Expand description
Wrap a Minimad Composite, which is a list of Compounds (which are strings with an homogeneous style)
Fields§
§composite: Composite<'s>
§visible_length: usize
§spacing: Option<Spacing>
Implementations§
source§impl<'s> FmtComposite<'s>
impl<'s> FmtComposite<'s>
pub fn new() -> Self
pub fn from(composite: Composite<'s>, skin: &MadSkin) -> Self
pub fn from_compound(compound: Compound<'s>) -> Self
sourcepub const fn completions(&self) -> (usize, usize)
pub const fn completions(&self) -> (usize, usize)
Return the number of characters (usually spaces) to insert both sides of the composite
sourcepub fn add_compound(&mut self, compound: Compound<'s>)
pub fn add_compound(&mut self, compound: Compound<'s>)
Add a compound and modifies visible_length
accordingly
sourcepub fn recompute_width(&mut self, skin: &MadSkin)
pub fn recompute_width(&mut self, skin: &MadSkin)
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
sourcepub fn fit_width(&mut self, width: usize, align: Alignment, skin: &MadSkin)
pub fn fit_width(&mut self, width: usize, align: Alignment, skin: &MadSkin)
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.
sourcepub fn extend_width(&mut self, width: usize, align: Alignment)
pub fn extend_width(&mut self, width: usize, align: Alignment)
if the composite is smaller than the given width, pad it according to the alignment.
sourcepub fn fill_width(&mut self, width: usize, align: Alignment, skin: &MadSkin)
pub fn fill_width(&mut self, width: usize, align: Alignment, skin: &MadSkin)
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§
source§impl<'s> Clone for FmtComposite<'s>
impl<'s> Clone for FmtComposite<'s>
source§fn clone(&self) -> FmtComposite<'s>
fn clone(&self) -> FmtComposite<'s>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more