pub struct BoxyBuilder { /* private fields */ }Expand description
The BoxyBuilder Struct. Used to initialize 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
impl BoxyBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new BoxyBuilder with default values.
let mut my_box = BoxyBuilder::new();Sourcepub fn box_type(self, box_type: BoxType) -> Self
pub fn box_type(self, box_type: BoxType) -> Self
Sets the border type for the Boxy instance.
my_box.box_type(BoxType::Double);Sourcepub fn color(self, box_color: &str) -> Self
pub fn color(self, box_color: &str) -> Self
Sets the border color for the Boxy instance.
my_box.color("#00ffff");Sourcepub fn add_segment(self, text: &str, color: &str) -> Self
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");Sourcepub fn add_line(self, text: &str, color: &str) -> Self
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");Sourcepub fn align(self, alignment: BoxAlign) -> Self
pub fn align(self, alignment: BoxAlign) -> Self
Sets the text alignment for the Boxy instance.
my_box.align(BoxAlign::Center);Sourcepub fn internal_padding(self, padding: BoxPad) -> Self
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));Sourcepub fn external_padding(self, padding: BoxPad) -> Self
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));Sourcepub fn padding(self, external: BoxPad, internal: BoxPad) -> Self
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));Sourcepub fn width(self, width: usize) -> Self
pub fn width(self, width: usize) -> Self
Sets a fixed width for the Boxy instance.
my_box.width(30);Sourcepub fn height(self, height: usize) -> Self
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);Sourcepub fn segment_ratios(self, seg_index: usize, ratios: Vec<usize>) -> Self
pub fn segment_ratios(self, seg_index: usize, ratios: Vec<usize>) -> Self
Sets the size ratios between segments for vertical divisions.
This feature is still experimental and not yet implemented fully, and hence may not work in the current version of the crate.
Sourcepub fn set_terminal_width_offset(self, offset: i32) -> Self
pub fn set_terminal_width_offset(self, offset: i32) -> Self
Sets the offset used when calculating the dynamic width of the textbox based on the terminal size.
By default, when fixed_width is not set, the textbox width is calculated as the terminal width minus 20.
This method allows you to overwrite this default offset. A positive value will make the textbox narrower,
while a negative value will widen it (and will most likely break the TextBox if it goes out of bounds of the terminal).
my_box.set_terminal_width_offset(10); // Make the box 10 characters narrower than the total terminal width