pub struct Palette;Expand description
Basic 16-color palette — SGR 30-37/90-97 only, no truecolor RGB.
Why 16 colors: truecolor RGB renders the same pixel regardless of terminal theme. On Mac Terminal.app’s default “Basic” (light) profile, our old lavender/mint/grays landed on a light background and all but disappeared. The 16-color SGR palette (30-37, 90-97) is interpreted by the terminal’s own theme engine — each user’s colorscheme remaps the same escape into theme-appropriate RGB, so atomcode adapts to whatever terminal theme the user runs.
Compatibility floor: SGR 30-37/90-97 are part of the 1996 ECMA-48
baseline. Every modern terminal (macOS Terminal, iTerm2, Alacritty,
Kitty, Wezterm, Windows Terminal, Win10 1511+ cmd.exe with VT mode,
tmux, SSH-in-SSH) handles them identically. We specifically avoid
\x1b[2m (dim) which isn’t reliable on Windows conhost < 1809.
Implementations§
Source§impl Palette
impl Palette
pub const BRAND: Color = Color::Magenta
Sourcepub const MUTED_LIGHT: Color = Color::DarkGrey
pub const MUTED_LIGHT: Color = Color::DarkGrey
Muted text on light backgrounds. SGR 90 (“bright black”) maps
to a mid-gray on most light themes — contrast against #FFFFFF
lands around 4.5–5:1, comfortably above AA.
Sourcepub const MUTED_DARK: Color = Color::White
pub const MUTED_DARK: Color = Color::White
Muted text on dark backgrounds. SGR 37 (“regular white”) maps
to a soft light-gray on dark themes — contrast against #1B1B1B
to #303030 lands around 8–10:1.
Earlier this was Color::DarkGrey (SGR 90) for both modes on the
theory that the terminal’s palette would adapt. Reality from
Warp / iTerm2 / Mac Terminal screenshots: most dark themes map
SGR 90 to ~#3F3F3F (≈ 3:1 against the dark bg) — child rows
under a tool-batch header rendered almost invisible. Splitting
MUTED into light/dark variants and switching via
is_light_for_render recovers readable contrast on both.
Sourcepub const MUTED: Color = Self::MUTED_LIGHT
pub const MUTED: Color = Self::MUTED_LIGHT
Back-compat alias — same value as MUTED_LIGHT so old call sites
that pre-date the dark-mode split keep compiling. New code should
call muted_for_current_theme instead so the shade tracks the
active palette.
pub const ACCENT: Color = Color::Cyan
pub const BORDER: Color = Color::Cyan
pub const WARNING: Color = Color::Yellow
pub const ERROR: Color = Color::Red
pub const DIFF_ADD: Color = Color::Green
pub const DIFF_REMOVE: Color = Color::Red
pub const CODE: Color = Color::Cyan
Auto Trait Implementations§
impl Freeze for Palette
impl RefUnwindSafe for Palette
impl Send for Palette
impl Sync for Palette
impl Unpin for Palette
impl UnsafeUnpin for Palette
impl UnwindSafe for Palette
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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