StyledText

Trait StyledText 

Source
pub trait StyledText {
    // Required methods
    fn style(self, style_name: &str, tcss: &Termio) -> StyledString;
    fn color(self, color: Color) -> StyledString;
    fn bg(self, color: Color) -> StyledString;
    fn decoration(self, decoration: Decoration) -> StyledString;
    fn padding(self, padding: u8) -> StyledString;
    fn padding_trbl(
        self,
        top: u8,
        right: u8,
        bottom: u8,
        left: u8,
    ) -> StyledString;
    fn margin(self, margin: u8) -> StyledString;
    fn border(self, style: BorderStyle) -> StyledString;
    fn border_color(self, color: Color) -> StyledString;
}
Expand description

A trait for text that can be styled using Termio.

This trait provides methods for applying styles to text elements. It is implemented for String and &str.

§Examples

use terminal_css::StyledText;
use terminal_css::Termio;

let tcss = Termio::from_file("examples/styles.tcss").unwrap();
let text = "Hello, World!".style("header", &tcss);

Required Methods§

Source

fn style(self, style_name: &str, tcss: &Termio) -> StyledString

Applies a style from the TCSS parser by name.

§Arguments
  • style_name - The name of the style to apply
  • tcss - The TCSS parser containing the styles
§Returns

A new StyledString instance with the applied style

Source

fn color(self, color: Color) -> StyledString

Set text color

Source

fn bg(self, color: Color) -> StyledString

Set background color

Source

fn decoration(self, decoration: Decoration) -> StyledString

Add decoration

Source

fn padding(self, padding: u8) -> StyledString

Set padding (all sides)

Source

fn padding_trbl(self, top: u8, right: u8, bottom: u8, left: u8) -> StyledString

Set padding for top, right, bottom, left

Source

fn margin(self, margin: u8) -> StyledString

Set margin (all sides)

Source

fn border(self, style: BorderStyle) -> StyledString

Set border style

Source

fn border_color(self, color: Color) -> StyledString

Set border color

Implementations on Foreign Types§

Source§

impl StyledText for &str

Source§

fn style(self, style_name: &str, tcss: &Termio) -> StyledString

Source§

fn color(self, color: Color) -> StyledString

Source§

fn bg(self, color: Color) -> StyledString

Source§

fn decoration(self, decoration: Decoration) -> StyledString

Source§

fn padding(self, padding: u8) -> StyledString

Source§

fn padding_trbl(self, top: u8, right: u8, bottom: u8, left: u8) -> StyledString

Source§

fn margin(self, margin: u8) -> StyledString

Source§

fn border(self, style: BorderStyle) -> StyledString

Source§

fn border_color(self, color: Color) -> StyledString

Source§

impl StyledText for String

Source§

fn style(self, style_name: &str, tcss: &Termio) -> StyledString

Source§

fn color(self, color: Color) -> StyledString

Source§

fn bg(self, color: Color) -> StyledString

Source§

fn decoration(self, decoration: Decoration) -> StyledString

Source§

fn padding(self, padding: u8) -> StyledString

Source§

fn padding_trbl(self, top: u8, right: u8, bottom: u8, left: u8) -> StyledString

Source§

fn margin(self, margin: u8) -> StyledString

Source§

fn border(self, style: BorderStyle) -> StyledString

Source§

fn border_color(self, color: Color) -> StyledString

Implementors§