pub struct StyledText { /* private fields */ }Expand description
Builder for creating complex styled text.
Allows chaining multiple styles and text segments to create rich formatted output.
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new()
.text("Found ")
.green("5")
.text(" packages: ")
.bold("@org/core")
.build();
println!("{}", text);Implementations§
Source§impl StyledText
impl StyledText
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new styled text builder.
§Examples
use sublime_cli_tools::output::StyledText;
let builder = StyledText::new();Sourcepub fn text(self, text: &str) -> Self
pub fn text(self, text: &str) -> Self
Adds plain text without styling.
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new()
.text("Hello ")
.text("world")
.build();Sourcepub fn green(self, text: &str) -> Self
pub fn green(self, text: &str) -> Self
Adds green text (success).
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new().green("Success").build();Sourcepub fn red(self, text: &str) -> Self
pub fn red(self, text: &str) -> Self
Adds red text (error).
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new().red("Error").build();Sourcepub fn yellow(self, text: &str) -> Self
pub fn yellow(self, text: &str) -> Self
Adds yellow text (warning).
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new().yellow("Warning").build();Sourcepub fn cyan(self, text: &str) -> Self
pub fn cyan(self, text: &str) -> Self
Adds cyan text (info).
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new().cyan("Info").build();Sourcepub fn bold(self, text: &str) -> Self
pub fn bold(self, text: &str) -> Self
Adds bold text.
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new().bold("Important").build();Sourcepub fn dim(self, text: &str) -> Self
pub fn dim(self, text: &str) -> Self
Adds dim text.
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new().dim("Secondary").build();Sourcepub fn italic(self, text: &str) -> Self
pub fn italic(self, text: &str) -> Self
Adds italic text.
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new().italic("Note").build();Sourcepub fn underline(self, text: &str) -> Self
pub fn underline(self, text: &str) -> Self
Adds underlined text.
§Examples
use sublime_cli_tools::output::StyledText;
let text = StyledText::new().underline("Link").build();Trait Implementations§
Source§impl Debug for StyledText
impl Debug for StyledText
Source§impl Default for StyledText
impl Default for StyledText
Source§fn default() -> StyledText
fn default() -> StyledText
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StyledText
impl RefUnwindSafe for StyledText
impl Send for StyledText
impl Sync for StyledText
impl Unpin for StyledText
impl UnwindSafe for StyledText
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