pub enum ColorProfile {
Mono,
Ansi16,
Ansi256,
TrueColor,
}Expand description
Terminal color profile used for downgrade decisions.
Variants§
Mono
No color output.
Ansi16
Standard 16 ANSI colors.
Ansi256
Extended 256-color palette.
TrueColor
Full 24-bit RGB color.
Implementations§
Source§impl ColorProfile
impl ColorProfile
Sourcepub fn detect() -> Self
pub fn detect() -> Self
Auto-detect the best available color profile from environment variables.
Detection priority:
NO_COLORset →MonoCOLORTERM=truecolororCOLORTERM=24bit→TrueColorTERMcontains “256” →Ansi256- Otherwise →
Ansi16
§Example
use ftui_style::ColorProfile;
let profile = ColorProfile::detect();
if profile.supports_true_color() {
println!("Full 24-bit color available!");
}Sourcepub fn detect_from_env(
no_color: Option<&str>,
colorterm: Option<&str>,
term: Option<&str>,
) -> Self
pub fn detect_from_env( no_color: Option<&str>, colorterm: Option<&str>, term: Option<&str>, ) -> Self
Detect color profile from provided environment values (for testing).
Pass Some("") for empty env vars or None for unset.
Sourcepub const fn from_flags(
true_color: bool,
colors_256: bool,
no_color: bool,
) -> Self
pub const fn from_flags( true_color: bool, colors_256: bool, no_color: bool, ) -> Self
Choose the best available profile from detection flags.
no_color should reflect explicit user intent (e.g. NO_COLOR).
Sourcepub const fn supports_true_color(self) -> bool
pub const fn supports_true_color(self) -> bool
Check if this profile supports 24-bit true color.
Sourcepub const fn supports_256_colors(self) -> bool
pub const fn supports_256_colors(self) -> bool
Check if this profile supports 256 colors or more.
Sourcepub const fn supports_color(self) -> bool
pub const fn supports_color(self) -> bool
Check if this profile supports any color (not monochrome).
Trait Implementations§
Source§impl Clone for ColorProfile
impl Clone for ColorProfile
Source§fn clone(&self) -> ColorProfile
fn clone(&self) -> ColorProfile
Returns a duplicate of the value. Read more
1.0.0 · 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 ColorProfile
impl Debug for ColorProfile
Source§impl Hash for ColorProfile
impl Hash for ColorProfile
Source§impl PartialEq for ColorProfile
impl PartialEq for ColorProfile
impl Copy for ColorProfile
impl Eq for ColorProfile
impl StructuralPartialEq for ColorProfile
Auto Trait Implementations§
impl Freeze for ColorProfile
impl RefUnwindSafe for ColorProfile
impl Send for ColorProfile
impl Sync for ColorProfile
impl Unpin for ColorProfile
impl UnwindSafe for ColorProfile
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