pub struct Padding { /* private fields */ }Expand description
Blank space around a child renderable. Mirrors rich.padding.Padding.
The pad is (top, right, bottom, left) — the same order as CSS and upstream.
Implementations§
Source§impl Padding
impl Padding
Sourcepub fn new(
child: Box<dyn Renderable>,
pad: (usize, usize, usize, usize),
) -> Self
pub fn new( child: Box<dyn Renderable>, pad: (usize, usize, usize, usize), ) -> Self
Pad child by an explicit (top, right, bottom, left).
Sourcepub fn indent(child: Box<dyn Renderable>, level: usize) -> Self
pub fn indent(child: Box<dyn Renderable>, level: usize) -> Self
Indent child by level cells without expanding it. Port of
Padding.indent (pad=(0, 0, 0, level), expand=False).
Sourcepub fn expand(self, expand: bool) -> Self
pub fn expand(self, expand: bool) -> Self
Expand to the available width (upstream expand=, default on), or fit
the child’s measured width plus the padding.
Sourcepub fn uniform(child: Box<dyn Renderable>, amount: usize) -> Self
pub fn uniform(child: Box<dyn Renderable>, amount: usize) -> Self
Equal padding on all four sides.
Sourcepub fn symmetric(
child: Box<dyn Renderable>,
vertical: usize,
horizontal: usize,
) -> Self
pub fn symmetric( child: Box<dyn Renderable>, vertical: usize, horizontal: usize, ) -> Self
(vertical, horizontal) padding (top==bottom, left==right).
Sourcepub fn style(self, style: impl Into<StyleType>) -> Self
pub fn style(self, style: impl Into<StyleType>) -> Self
Set the style applied to the padding (and blank lines): a Style,
or a theme name or style definition resolved at render time, as
upstream’s style= is.
Sourcepub fn unpack(pad: &[usize]) -> Option<(usize, usize, usize, usize)>
pub fn unpack(pad: &[usize]) -> Option<(usize, usize, usize, usize)>
Unpack padding given CSS style, as (top, right, bottom, left). Port
of Padding.unpack: one value pads every side, two are
(vertical, horizontal) and four are explicit. Any other count is
None, where upstream raises ValueError.
Trait Implementations§
Source§impl Renderable for Padding
impl Renderable for Padding
Source§fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
Port of Padding.__rich_measure__: the child’s measurement plus the
horizontal padding, or the whole width when the padding leaves no room.
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
Console::print shrinks this renderable to its
measured width. Upstream renders every top-level renderable at the full
console width, so the default is false; an extension may opt in.Source§fn vertical(&self) -> Option<VerticalAlign>
fn vertical(&self) -> Option<VerticalAlign>
Table cell holding this renderable uses in
place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.Source§fn print_end_line(&self, _options: &ConsoleOptions) -> bool
fn print_end_line(&self, _options: &ConsoleOptions) -> bool
"\n", so a print adds the final line break. A renderable
whose upstream output stops without one (Screen, LiveRender, a
Rule whose end has no newline) returns false, and the next
output continues its last line. options are the print’s options.