pub struct Style { /* private fields */ }Expand description
Composable text style. Builds ANSI escape sequences for foreground, background, bold, italic, underline, and strikethrough.
Create via builder methods and apply with apply():
let styled = rab::tui::Style::new().bg("\x1b[48;2;52;53;65m".to_string()).bold().apply("hello");
assert!(styled.starts_with("\x1b[48"));
assert!(styled.contains("hello"));Implementations§
Source§impl Style
impl Style
pub fn new() -> Self
Sourcepub fn strikethrough(self) -> Self
pub fn strikethrough(self) -> Self
Enable strikethrough.
Sourcepub fn apply(&self, text: &str) -> String
pub fn apply(&self, text: &str) -> String
Apply this style to text, returning ANSI-wrapped string. The text is wrapped with opening escape sequences at the start and closing sequences at the end.
Sourcepub fn apply_padded(&self, text: &str, width: usize) -> String
pub fn apply_padded(&self, text: &str, width: usize) -> String
Apply this style to text, padding to width visible columns.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnsafeUnpin for Style
impl UnwindSafe for Style
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