(mode: ThemeMode)
| 196 | /// temporarily enters raw mode itself and restores it afterward. |
| 197 | #[must_use] |
| 198 | pub fn detect(mode: ThemeMode) -> Theme { |
| 199 | match mode { |
| 200 | ThemeMode::Dark => Theme::dark(), |
| 201 | ThemeMode::Light => Theme::light(), |
| 202 | ThemeMode::Auto => { |
| 203 | if is_light_terminal() { |
| 204 | Theme::light() |
| 205 | } else { |
| 206 | Theme::dark() |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /// Detect whether the terminal has a light background using OSC 11. |
| 213 | /// |