Files
codex/codex-rs/tui/src/render/model_themes.rs
T
Eric Traut 907b751eab Add six bundled TUI themes and theme-aware accents (#46504)
## What changed

- Bundle `ada`, `babbage`, `curie`, `cushman`, `dali`, and `davinci` themes for configuration and the theme picker, preserving precedence and invalid-file warnings for custom themes with the same names.
- Use `codex.accent` for active and selected controls on truecolor and 256-color terminals, retaining existing fallbacks at lower color depths.
- Honor terminal-default diff backgrounds and clear matching gutter fills, allowing `dali` and `davinci` to show diffs without background fills.
- Restrict Windows native palette fallback to `ConsoleWindowClass` so a ConPTY palette is not mistaken for the renderer's colors when OSC probing fails.

## Testing

Add tests and snapshots for theme preview, selection, cancellation, custom-theme precedence, invalid-file warnings, accent color depth, and disabling individual diff fills.

GitOrigin-RevId: 72f3ef08f82626436dd2d80d40210cc77e1a5616
2026-09-18 23:16:04 +00:00

29 lines
891 B
Rust

//! Fixed model-named theme assets loaded through the standard TextMate parser.
use std::io::Cursor;
use syntect::highlighting::Theme;
use syntect::highlighting::ThemeSet;
pub(super) const THEMES: &[(&str, &str)] = &[
("ada", include_str!("../../assets/themes/ada.tmTheme")),
(
"babbage",
include_str!("../../assets/themes/babbage.tmTheme"),
),
("curie", include_str!("../../assets/themes/curie.tmTheme")),
(
"cushman",
include_str!("../../assets/themes/cushman.tmTheme"),
),
("dali", include_str!("../../assets/themes/dali.tmTheme")),
(
"davinci",
include_str!("../../assets/themes/davinci.tmTheme"),
),
];
pub(super) fn resolve(name: &str) -> Option<Theme> {
let (_, source) = THEMES.iter().find(|(key, _)| *key == name)?;
ThemeSet::load_from_reader(&mut Cursor::new(source.as_bytes())).ok()
}