pub struct ThemedStyle { /* private fields */ }Expand description
Single style slot held by Theme. Wraps console::Style (used for the
256-color fallback path and for non-color attributes like bold/dim) and
optionally carries an (r, g, b) triple for high-fidelity rendering on
truecolor-capable terminals. The decision between truecolor and 256-color
is taken at render time inside apply_to, so existing call sites are
unaffected by the upgrade.
Implementations§
Source§impl ThemedStyle
impl ThemedStyle
Sourcepub fn from_hex(hex: &str) -> Self
pub fn from_hex(hex: &str) -> Self
Build a style from a #rrggbb hex string. On terminals that advertise
truecolor support (COLORTERM=truecolor|24bit), apply_to emits the
exact 24-bit color. Otherwise the color is quantized to the nearest
ANSI 256-color slot for compatibility.
pub fn bold(self) -> Self
pub fn dim(self) -> Self
pub fn italic(self) -> Self
pub fn underlined(self) -> Self
pub fn cyan(self) -> Self
pub fn red(self) -> Self
pub fn green(self) -> Self
pub fn yellow(self) -> Self
Sourcepub fn apply_to<D: Display>(&self, text: D) -> StyledText<'_, D>
pub fn apply_to<D: Display>(&self, text: D) -> StyledText<'_, D>
Wrap text for Display rendering. Resolved at format-time:
console::colors_enabled()is false (NO_COLOR / TERM=dumb / not a tty) AND no attrs → emittextwith no escapes.console::colors_enabled()is false AND attrs are set → emit\x1b[<attrs>m{text}\x1b[0m. NO_COLOR (per no-color.org) governs color only — bold/dim/italic/underline are independent SGR signals load-bearing for thedefault(italic accent) andminimal(italic accent, underlined secondary) presets that intentionally carry the accent/secondary distinction in non-color attrs.supports_truecolor()is true AND an RGB triple is present → emit\x1b[<attrs>;38;2;R;G;Bm{text}\x1b[0m.- Otherwise → delegate to
console::Style::apply_to, which yields the 256-color fallback path (existing behavior).
Trait Implementations§
Source§impl Clone for ThemedStyle
impl Clone for ThemedStyle
Source§fn clone(&self) -> ThemedStyle
fn clone(&self) -> ThemedStyle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ThemedStyle
impl Debug for ThemedStyle
Source§impl Default for ThemedStyle
impl Default for ThemedStyle
Source§fn default() -> ThemedStyle
fn default() -> ThemedStyle
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ThemedStyle
impl RefUnwindSafe for ThemedStyle
impl Send for ThemedStyle
impl Sync for ThemedStyle
impl Unpin for ThemedStyle
impl UnsafeUnpin for ThemedStyle
impl UnwindSafe for ThemedStyle
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