1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Indexed-color theme substitution — the one place that decides a
//! session's theme must be swapped because the terminal can't render
//! 24-bit color, shared by the two paths that resolve a theme from a
//! freshly-read `Config`: [`crate::app::App::new`] at startup and the
//! external-editor reload in [`crate::app::external_editor`].
//!
//! Keeping it here (rather than inline in `App::new`) is what stops the
//! reload path from quietly undoing the swap: `Config::load` returns the
//! user's on-disk theme every time, so without re-applying, exiting
//! `$EDITOR` would repaint the session in the unreadable palette.
//!
//! See [`crate::app::modal::ThemeDowngradeModal`] for what the user is
//! told, and `Config::theme_downgraded_from` for how the substitution is
//! kept out of `config.toml`.
use crateindexed_fallback_theme;
use crate;
use crate;
/// A substitution that fired. `configured` is the user's own theme
/// (already stashed in `Config::theme_downgraded_from`); `substituted`
/// is the indexed-color built-in now in `Config::theme`.
pub
/// Swap `config.theme` for an indexed-color built-in when `caps` lacks
/// 24-bit color, stashing the user's choice. Returns the `ThemeFile`
/// the caller should render with, or `None` when no swap is needed —
/// on a truecolor terminal, on a colorless one, or when the configured
/// theme is already in `theme::INDEXED_SAFE_THEMES` (which is also what
/// keeps the swap idempotent across reloads).
///
/// Because `App::new` derives both the substitution and the modal from
/// this one `Option`, returning `None` suppresses the warning and the
/// swap together — there is no second predicate to keep in sync.
pub