1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-28 07:55:03 +03:00
wezterm/window/src/configuration.rs

27 lines
706 B
Rust
Raw Normal View History

use std::sync::{Arc, Mutex};
pub trait WindowConfiguration {
fn use_ime(&self) -> bool {
false
}
}
lazy_static::lazy_static! {
static ref CONFIG: Mutex<Arc<dyn WindowConfiguration + Send + Sync>> = default_config();
}
pub(crate) fn config() -> Arc<dyn WindowConfiguration + Send + Sync> {
Arc::clone(&CONFIG.lock().unwrap())
}
fn default_config() -> Mutex<Arc<dyn WindowConfiguration + Send + Sync>> {
struct DefConfig;
impl WindowConfiguration for DefConfig {}
Mutex::new(Arc::new(DefConfig))
}
pub fn set_configuration<C: WindowConfiguration + Send + Sync + 'static>(c: C) {
let mut global_config = CONFIG.lock().unwrap();
*global_config = Arc::new(c);
}