(s: &str)
| 229 | |
| 230 | #[allow(dead_code)] |
| 231 | fn parse_osc_color(s: &str) -> Option<(u8, u8, u8)> { |
| 232 | if let Some(hex) = s.strip_prefix('#') { |
| 233 | if hex.len() == 6 { |
| 234 | let r = u8::from_str_radix(&hex[0..2], 16).ok()?; |
| 235 | let g = u8::from_str_radix(&hex[2..4], 16).ok()?; |
| 236 | let b = u8::from_str_radix(&hex[4..6], 16).ok()?; |
| 237 | return Some((r, g, b)); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | if let Some(rgb) = s.strip_prefix("rgb:") { |
| 242 | let parts: Vec<&str> = rgb.split('/').collect(); |
| 243 | if parts.len() == 3 { |
| 244 | let r16 = u16::from_str_radix(parts[0], 16).ok()?; |
| 245 | let g16 = u16::from_str_radix(parts[1], 16).ok()?; |
| 246 | let b16 = u16::from_str_radix(parts[2], 16).ok()?; |
| 247 | return Some(((r16 >> 8) as u8, (g16 >> 8) as u8, (b16 >> 8) as u8)); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | if let Some(rgb) = s.strip_prefix("rgb(").and_then(|t| t.strip_suffix(')')) { |
| 252 | let parts: Vec<&str> = rgb.split(',').map(|p| p.trim()).collect(); |
| 253 | if parts.len() == 3 { |
| 254 | let r = parts[0].parse::<u8>().ok()?; |
| 255 | let g = parts[1].parse::<u8>().ok()?; |
| 256 | let b = parts[2].parse::<u8>().ok()?; |
| 257 | return Some((r, g, b)); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | None |
| 262 | } |
| 263 | |
| 264 | impl Theme { |
| 265 | pub fn dark() -> Self { |
no test coverage detected