[][src]Struct text_block_layout::Block

pub struct Block { /* fields omitted */ }

Represents a block of some width an height containing text.

Implementations

impl Block[src]

pub fn empty() -> Block[src]

Create empty block with width and height zero

pub fn of_width(width: usize) -> Block[src]

Create block of given width and height 0.

pub fn of_height(height: usize) -> Block[src]

Create block of given height and width 0.

pub fn of_text(text: &str) -> Block[src]

Create block containing given text. Gets width of the text and height 1.

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

Return height of block.

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

Return width of block.

pub fn add_text(&self, text: &str) -> Block[src]

Add given text at bottom of block, incementing the height. Width of block will be increased if needed for added line to fit.

pub fn add_multiple_texts(&self, texts: &[String]) -> Block[src]

Add given text lines at bottom of block, incrementing the height accordingly. Width of block will be increades if needed.

pub fn fill_right(&self, width: usize, filler: char) -> Block[src]

Fill right side of block with given number of the filler character.

pub fn fill_bottom(&self, height: usize, filler: char) -> Block[src]

Fill bottom side of block with given number of the filler character.

pub fn pad_right(&self, width: usize) -> Block[src]

Pad right side of block with given number of spaces.

pub fn pad_left(&self, width: usize) -> Block[src]

Pad left side of block with given number of spaces.

pub fn pad_top(&self, height: usize) -> Block[src]

pub fn pad_bottom(&self, height: usize) -> Block[src]

Pad bottom side of block with given number of empty lines.

pub fn pad_to_width_right(&self, width: usize) -> Block[src]

Pad right so given width is reached. Wider block is untouched.

pub fn pad_to_width_left(&self, width: usize) -> Block[src]

Pad left so given width is reached. Wider block is untouched.

pub fn pad_to_width_center_right(&self, width: usize) -> Block[src]

Pad both sides so given width is reached. Wider block is untouched. If padding needs to be uneven, there will be more padding on the right side.

pub fn pad_to_width_center_left(&self, width: usize) -> Block[src]

Pad both sides so given width is reached. Wider block is untouched. If padding needs to be uneven, there will be more padding on the left side.

pub fn pad_to_height_top(&self, height: usize) -> Block[src]

Pad top so given height is reached. Higher block is untouched.

pub fn pad_to_height_bottom(&self, height: usize) -> Block[src]

Pad bottom so given height is reached. Higher block is untouched.

pub fn pad_to_height_center_top(&self, height: usize) -> Block[src]

Pad both top and bottom so given height is reached. Higher block is untouched. If padding needs to be uneven, there will be more padding on the top side.

pub fn pad_to_height_center_bottom(&self, height: usize) -> Block[src]

Pad both top and bottom so given height is reached. Higher block is untouched. If padding needs to be uneven, there will be more padding on the bottom side.

pub fn beside_top(&self, right: &Block) -> Block[src]

Join two blocks horizontally, self to the left and the given block to the right, aligning the top side of the blocks.

pub fn beside_bottom(&self, right: &Block) -> Block[src]

Join two blocks horizontally, self to the left and the given block to the right, aligning the bottom side of the blocks.

pub fn beside_center_bottom(&self, right: &Block) -> Block[src]

Join two blocks horizontally, self to the left and the given block to the right, aligning the center of the blocks. If padding needs to be uneven, there will be more padding on the top side.

pub fn beside_center_top(&self, right: &Block) -> Block[src]

Join two blocks horizontally, self to the left and the given block to the right, aligning the center of the blocks. If padding needs to be uneven, there will be more padding on the bottom side.

pub fn stack_right(&self, bottom: &Block) -> Block[src]

Join two blocks vertically, self on the top and the given block on the bottom, aligning the right side of the blocks.

pub fn stack_left(&self, bottom: &Block) -> Block[src]

Join two blocks vertically, self on the top and the given block on the bottom, aligning the left side of the blocks.

pub fn stack_center_left(&self, bottom: &Block) -> Block[src]

Join two blocks vertically, self on the top and the given block on the bottom, aligning the center of the blocks. If padding needs to be uneven, there will be more padding on the right side.

pub fn stack_center_right(&self, bottom: &Block) -> Block[src]

Join two blocks vertically, self on the top and the given block on the bottom, aligning the center of the blocks. If padding needs to be uneven, there will be more padding on the left side.

pub fn in_front_of(&self, behind: &Block) -> Block[src]

Overlays self in front of given block. Treats spaces as transparent characters.

pub fn in_front_of_with_transparency(
    &self,
    behind: &Block,
    transparency: char
) -> Block
[src]

Overlays self in front of given block, showing content of the block behind on the characters defined as transparent.

pub fn render(&self) -> String[src]

Render a string from a block using '\n' as separator between lines. Trims away whitespace on the right side of each line, just to save on final string length.

Trait Implementations

impl Clone for Block[src]

impl Debug for Block[src]

impl Eq for Block[src]

impl From<&'_ str> for Block[src]

impl From<String> for Block[src]

impl From<char> for Block[src]

impl Hash for Block[src]

impl PartialEq<Block> for Block[src]

impl StructuralEq for Block[src]

impl StructuralPartialEq for Block[src]

impl ToString for Block[src]

Auto Trait Implementations

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.