apply color scheme changes to realm

This commit is contained in:
Bruce Leidl 2021-11-29 16:20:58 -05:00
parent ea70bfc65e
commit 663478072c

View File

@ -58,7 +58,7 @@ fn configure_realm_boolean_config(realm: &Realm, variable: &str, value: &str) {
save_config(realm); save_config(realm);
} }
fn configure_realm(realm: &Realm, variable: &str, value: &str) { fn configure_realm(manager: &RealmManager, realm: &Realm, variable: &str, value: &str) {
if is_bool_config_variable(variable) { if is_bool_config_variable(variable) {
configure_realm_boolean_config(realm, variable, value); configure_realm_boolean_config(realm, variable, value);
} else if variable == "overlay" { } else if variable == "overlay" {
@ -72,9 +72,16 @@ fn configure_realm(realm: &Realm, variable: &str, value: &str) {
return; return;
} }
} else if variable == "terminal-scheme" { } else if variable == "terminal-scheme" {
if Base16Scheme::by_name(value).is_none() { match Base16Scheme::by_name(value) {
warn!("No terminal color scheme with name '{}' available", value); Some(scheme) => if let Err(err) = scheme.apply_to_realm(manager, realm) {
} warn!("Error applying terminal color scheme '{}' to realm-{}: {}", value, realm.name(), err);
return;
},
None => {
warn!("No terminal color scheme with name '{}' available", value);
return;
},
};
realm.with_mut_config(|c| { realm.with_mut_config(|c| {
c.terminal_scheme = Some(value.to_string()); c.terminal_scheme = Some(value.to_string());
}); });
@ -241,7 +248,7 @@ impl RealmsManagerServer {
}; };
for var in &vars { for var in &vars {
configure_realm(&realm, &var.0, &var.1); configure_realm(&self.manager, &realm, &var.0, &var.1);
} }
} }