Struct BoxyBuilder

Source
pub struct BoxyBuilder { /* private fields */ }
Expand description

The BoxyBuilder Struct. Used to initialise and create Boxy Structs, the precursor to the textboxes.

Use the build method once done configuring to build the Boxy Stuct and then use the display method on it to display the textbox

Implementations§

Source§

impl BoxyBuilder

Source

pub fn new() -> Self

Creates a new BoxyBuilder with default values.

let mut my_box = BoxyBuilder::new();
Source

pub fn box_type(self, box_type: BoxType) -> Self

Sets the border type for the Boxy instance.

my_box.box_type(BoxType::Double);
Source

pub fn color(self, box_color: &str) -> Self

Sets the border color for the Boxy instance.

my_box.color("#00ffff");
Source

pub fn add_segment(self, text: &str, color: &str) -> Self

Adds a new text segment with its color.

my_box.add_segment("Lorem ipsum dolor sit amet", "#ffffff");
Source

pub fn add_line(self, text: &str, color: &str) -> Self

Adds a new text line to the last added segment with its color.

my_box = my_box.add_segment("Lorem ipsum dolor sit amet", "#ffffff");
my_box.add_line("This is a new line!!!", "#ffffff");
Source

pub fn align(self, alignment: BoxAlign) -> Self

Sets the text alignment for the Boxy instance.

my_box.align(BoxAlign::Center);
Source

pub fn internal_padding(self, padding: BoxPad) -> Self

Sets the internal padding for the Boxy instance.

my_box.internal_padding(BoxPad::from_tldr(1,2,1,2));
Source

pub fn external_padding(self, padding: BoxPad) -> Self

Sets the external padding for the Boxy instance.

my_box.external_padding(BoxPad::from_tldr(3,4,3,4));
Source

pub fn padding(self, external: BoxPad, internal: BoxPad) -> Self

Sets both internal and external padding.

my_box.padding(BoxPad::from_tldr(3,4,3,4), BoxPad::from_tldr(1,2,1,2));
Source

pub fn width(self, width: usize) -> Self

Sets a fixed width for the Boxy instance.

my_box.width(30);
Source

pub fn height(self, height: usize) -> Self

Sets a fixed height for the Boxy instance.

This feature is still experimental, and may not work

my_box.height(50);
Source

pub fn segment_ratios(self, seg_index: usize, ratios: Vec<usize>) -> Self

Sets the size ratios between segments for vertical divisions.

Source

pub fn build(self) -> Boxy

Builds the Boxy instance.

my_box.build();

Subsequently, disply using display()

my_box.build().display();

Trait Implementations§

Source§

impl Debug for BoxyBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BoxyBuilder

Source§

fn default() -> BoxyBuilder

Returns the “default value” for a type. Read more

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.