pub struct SGRString {Show 15 fields
pub text: String,
pub clean: CleanKind,
pub custom_places: Vec<u8>,
pub custom_cleans: Vec<u8>,
pub foreground: ColorKind,
pub background: ColorKind,
pub reset: bool,
pub bold: StyleKind,
pub dim: StyleKind,
pub italic: StyleKind,
pub underline: StyleKind,
pub blinking: StyleKind,
pub inverse: StyleKind,
pub hidden: StyleKind,
pub strikethrough: StyleKind,
}Expand description
A String encapsulating the usage of SGR codes
SGR codes are applied when the Display trait is used,
or when the SGRString::place_all or SGRString::clean_all
functions are called.
Writing is done through the use of the writing module
Examples
use easy_sgr::{ColorKind, SGRString, StyleKind};
let mut string = SGRString::default();
string.text = String::from("This is my text");
string.bold = StyleKind::Place;
string.foreground = ColorKind::Red;
println!("{string}");Fields§
§text: StringThe actual text
clean: CleanKindThe type of clean to apply when SGRString::clean_all is called
By default CleanKind::None, meaning nothing is done
custom_places: Vec<u8>Any custom codes added
These codes are written before the string when
the Display trait is called
custom_cleans: Vec<u8>Any custom codes added
These codes are written after the string when
the Display trait is called
foreground: ColorKindThe color of the foreground
By default ColorKind::None, meaning nothing is applied.
Not to be confused with ColorKind::Default, where the default SGR
code for the foreground is applied.
background: ColorKindThe color of the background
By default ColorKind::None, meaning nothing is applied.
Not to be confused with ColorKind::Default, where the default SGR
code for the background is applied.
reset: boolDetermines whether the clear code 0 is to be applied to the beginning
Not be confused with [SGRString.clean], this effects SGRString::place_all
bold: StyleKindRefer to StyleKind
dim: StyleKindRefer to StyleKind
italic: StyleKindRefer to StyleKind
underline: StyleKindRefer to StyleKind
blinking: StyleKindRefer to StyleKind
inverse: StyleKindRefer to StyleKind
Refer to StyleKind
strikethrough: StyleKindRefer to StyleKind
Implementations§
source§impl SGRString
impl SGRString
sourcepub fn place_all(&self, builder: &mut SGRBuilder)
pub fn place_all(&self, builder: &mut SGRBuilder)
Writes all contained SGR codes to the given SGRBuilder
Does not perform any IO operations
sourcepub fn place_colors(&self, builder: &mut SGRBuilder)
pub fn place_colors(&self, builder: &mut SGRBuilder)
Writes contained SGR color codes to the given SGRWriter
Does not perform any IO operations
sourcepub fn place_styles(&self, builder: &mut SGRBuilder)
pub fn place_styles(&self, builder: &mut SGRBuilder)
Writes SGR style codes to the given SGRWriter
Does not perform any IO operations
sourcepub fn place_custom(&self, builder: &mut SGRBuilder)
pub fn place_custom(&self, builder: &mut SGRBuilder)
Writes custom SGR codes to the given SGRWriter
Does not perform any IO operations
sourcepub fn clean_all(&self, builder: &mut SGRBuilder)
pub fn clean_all(&self, builder: &mut SGRBuilder)
Writes contained SGR codes to the given SGRWriter
Reverses the effects of SGRString::place_all
Does not perform any IO operations
sourcepub fn clean_colors(&self, builder: &mut SGRBuilder)
pub fn clean_colors(&self, builder: &mut SGRBuilder)
Writes SGR color codes to the given SGRWriter
Reverses the effects of SGRString::place_colors
Does not perform any IO operations
sourcepub fn clean_styles(&self, builder: &mut SGRBuilder)
pub fn clean_styles(&self, builder: &mut SGRBuilder)
Writes SGR style codes to the given SGRWriter
Reverses the effects of SGRString::place_styles
Does not perform any IO operations
sourcepub fn clean_custom(&self, builder: &mut SGRBuilder)
pub fn clean_custom(&self, builder: &mut SGRBuilder)
Writes SGR codes to the given SGRWriter
Reverses the effects of SGRString::place_custom
Does not perform any IO operations
Trait Implementations§
source§impl EasyWrite for SGRString
impl EasyWrite for SGRString
source§fn sgr(&self, builder: &mut SGRBuilder)
fn sgr(&self, builder: &mut SGRBuilder)
Writes a set of codes to the builder
Uses SGRString::place_all
Auto Trait Implementations§
impl RefUnwindSafe for SGRString
impl Send for SGRString
impl Sync for SGRString
impl Unpin for SGRString
impl UnwindSafe for SGRString
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
source§impl<I> EasySGR for Iwhere
I: Into<SGRString>,
impl<I> EasySGR for Iwhere I: Into<SGRString>,
source§fn text(self, text: impl Into<String>) -> SGRString
fn text(self, text: impl Into<String>) -> SGRString
SGRString source§fn color(self, color: impl Into<Color>) -> SGRString
fn color(self, color: impl Into<Color>) -> SGRString
SGRString