Skip to main content

Padding

Struct Padding 

Source
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

Source

pub fn new( child: Box<dyn Renderable>, pad: (usize, usize, usize, usize), ) -> Self

Pad child by an explicit (top, right, bottom, left).

Source

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).

Source

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.

Source

pub fn uniform(child: Box<dyn Renderable>, amount: usize) -> Self

Equal padding on all four sides.

Source

pub fn symmetric( child: Box<dyn Renderable>, vertical: usize, horizontal: usize, ) -> Self

(vertical, horizontal) padding (top==bottom, left==right).

Source

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.

Source

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

Source§

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.

Source§

fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Source§

fn fit_to_measurement(&self) -> bool

Whether a top-level 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>

The vertical alignment a 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

Whether a top-level print ends this renderable’s last line. This port’s renderables separate lines, where upstream’s end each line with "\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.

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, 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.