pub struct BoxPad {
pub top: usize,
pub down: usize,
pub left: usize,
pub right: usize,
}Expand description
Represents padding values for the text box in all four directions.
BoxPad is used to specify padding between:
- The box border and the contained text (internal padding)
- The terminal edges and the box itself (external padding)
§Examples
use boxy_cli::prelude::*;
// Create uniform padding of 2 spaces on all sides
let uniform_padding = BoxPad::uniform(2);
// Create custom padding for each side
let custom_padding = BoxPad::from_tldr(1, 3, 1, 3); // top, left, down, right
// Create horizontal/vertical padding
let h_v_padding = BoxPad::vh(1, 3); // 1 vertical, 3 horizontalFields§
§top: usizePadding at the top
down: usizePadding at the bottom
left: usizePadding on the left side
right: usizePadding on the right side
Implementations§
Source§impl BoxPad
impl BoxPad
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new BoxPad instance with zero padding on all sides.
§Examples
use boxy_cli::prelude::*;
let padding = BoxPad::new();
// Equivalent to BoxPad { top: 0, down: 0, left: 0, right: 0 }Sourcepub fn from_tldr(top: usize, left: usize, down: usize, right: usize) -> Self
pub fn from_tldr(top: usize, left: usize, down: usize, right: usize) -> Self
Creates a new BoxPad with specific values for each side.
The parameter order follows the mnemonic “tldr” (top, left, down, right).
§Arguments
top- Padding at the topleft- Padding on the left sidedown- Padding at the bottomright- Padding on the right side
§Examples
use boxy_cli::prelude::*;
// Create padding with different values on each side
let padding = BoxPad::from_tldr(2, 4, 2, 4);
// top: 2, left: 4, down: 2, right: 4Sourcepub fn uniform(pad: usize) -> Self
pub fn uniform(pad: usize) -> Self
Creates a new BoxPad with the same padding value on all sides.
§Arguments
pad- The padding value to use for all sides
§Examples
use boxy_cli::prelude::*;
// Create uniform padding of 3 spaces on all sides
let padding = BoxPad::uniform(3);
// Equivalent to BoxPad { top: 3, down: 3, left: 3, right: 3 }Sourcepub fn vh(vertical: usize, horizontal: usize) -> Self
pub fn vh(vertical: usize, horizontal: usize) -> Self
Creates a new BoxPad with separate values for vertical and horizontal padding.
This is a convenience method that applies the same padding to top/bottom and left/right sides.
§Arguments
vertical- Padding for top and bottomhorizontal- Padding for left and right
§Examples
use boxy_cli::prelude::*;
// Create padding with 1 space vertically and 3 spaces horizontally
let padding = BoxPad::vh(1, 3);
// Equivalent to BoxPad { top: 1, down: 1, left: 3, right: 3 }Trait Implementations§
Auto Trait Implementations§
impl Freeze for BoxPad
impl RefUnwindSafe for BoxPad
impl Send for BoxPad
impl Sync for BoxPad
impl Unpin for BoxPad
impl UnwindSafe for BoxPad
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more