pub enum Fidelity {
Ansi16,
Ansi256,
TrueColor,
}Expand description
How many colours the terminal can actually show.
Only Fidelity::Ansi16 changes what this crate draws. Above it, colour
separates a raised surface from a well on every shipped theme, and the
glyph fallback below never fires. Recorded rather than inferred, because a
caller that quantised its palette knows the answer and this crate cannot
recover it from the colours afterwards.
Variants§
Ansi16
Sixteen colours. Depth cannot be carried by colour: a well collapses onto its face on 18 of 31 themes and a bevel loses an edge on all 31.
Ansi256
The 6x6x6 cube and the grey ramp. Enough on 27 of 31 themes.
TrueColor
24-bit. The only failures left belong to the theme, not the terminal.
Implementations§
Source§impl Fidelity
impl Fidelity
Sourcepub fn detect() -> Self
pub fn detect() -> Self
Read the terminal’s own claim, from COLORTERM then TERM.
Deliberately credulous, and the fall-through is where that is decided.
An unrecognised TERM is assumed capable, because the two wrong answers
do not cost the same: guessing TrueColor on a
limited terminal costs some fidelity, and guessing
Ansi16 on a capable one throws away colour the user
paid for — and, for a caller that quantises its palette off this answer,
throws away the whole theme. COLORTERM is routinely stripped by ssh
and by multiplexers, so an unrecognised name is the common case rather
than the exotic one: foot, xterm and screen all land here.
So sixteen colours is reached by naming the terminals that really have
them. The list is short and it does not grow: these are the fixed
consoles, and TERM=linux is the case this exists for — the Linux
virtual console, which is what an installer and a machine with no
desktop draw on.
Sourcepub fn from_env(colorterm: &str, term: &str) -> Self
pub fn from_env(colorterm: &str, term: &str) -> Self
detect with the environment passed in, so the decision
can be tested without mutating a process-wide variable from a parallel
test.
Sourcepub const fn separates_depth(self) -> bool
pub const fn separates_depth(self) -> bool
Whether colour alone can tell a raised surface from a well here.
Trait Implementations§
impl Copy for Fidelity
impl Eq for Fidelity
impl StructuralPartialEq for Fidelity
Auto Trait Implementations§
impl Freeze for Fidelity
impl RefUnwindSafe for Fidelity
impl Send for Fidelity
impl Sync for Fidelity
impl Unpin for Fidelity
impl UnsafeUnpin for Fidelity
impl UnwindSafe for Fidelity
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more