Function blockfmt_advanced

Source
pub fn blockfmt_advanced(
    content: impl ToString,
    color: Option<Color>,
    preset: &str,
    arrangement: ContentArrangement,
    alignment: CellAlignment,
) -> String
Expand description

Formats content with a border around it

Unless you are looking for something specific, use blockfmt or blockprint.

The border can be created using box-drawing characters, and the content is formatted within the border. The function allows customization of the border’s color, preset, content arrangement, and cell alignment.

§Example

use comfy_table::{presets, CellAlignment, ContentArrangement};
use console::Color;
use libpt_cli::printing::blockfmt_advanced;
println!(
    "{}",
    blockfmt_advanced(
        "Hello world!",
        Some(Color::Blue),
        presets::UTF8_FULL,
        ContentArrangement::DynamicFullWidth,
        CellAlignment::Center
    )
);
┌────────────────────────────────────────────────────────────────────────────────────────┐
│                                      Hello world!                                      │
└────────────────────────────────────────────────────────────────────────────────────────┘

§Parameters

  • content: The content to be formatted within the border
  • color: The color of the border and text
  • preset: The preset style for the border
  • arrangement: The arrangement of the the border (e.g., stretch to sides, wrap around )
  • alignment: The alignment of the content within the cells (e.g., left, center, right)