Skip to main content

Mountain/IPC/WindServiceHandlers/UI/
ThemesGetActive.rs

1//! Wire method: `themes:getColorTheme`.
2
3use std::sync::Arc;
4
5use serde_json::{Value, json};
6
7use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
8
9pub async fn Fn(RunTime:Arc<ApplicationRunTime>) -> Result<Value, String> {
10	use CommonLibrary::Configuration::{
11		ConfigurationProvider::ConfigurationProvider,
12		DTO::ConfigurationOverridesDTO::ConfigurationOverridesDTO,
13	};
14
15	let ThemeId = RunTime
16		.Environment
17		.GetConfigurationValue(Some("workbench.colorTheme".to_string()), ConfigurationOverridesDTO::default())
18		.await
19		.map_err(|Error| format!("themes:getActive failed: {}", Error))?;
20
21	let Id = ThemeId.as_str().unwrap_or("Default Dark Modern").to_string();
22
23	let (Kind, TypeNum) = if Id.to_lowercase().contains("high contrast light") {
24		("highContrastLight", 4u8)
25	} else if Id.to_lowercase().contains("high contrast") {
26		("highContrast", 3u8)
27	} else if Id.to_lowercase().contains("light") {
28		("light", 1u8)
29	} else {
30		("dark", 2u8)
31	};
32
33	Ok(json!({
34		"id": Id,
35		"label": Id,
36		"kind": Kind,
37		"type": TypeNum,
38		"semanticHighlighting": false,
39	}))
40}