diff options
Diffstat (limited to 'alacritty/src/config/mod.rs')
-rw-r--r-- | alacritty/src/config/mod.rs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/alacritty/src/config/mod.rs b/alacritty/src/config/mod.rs index 4a3c0ae9..10e504d3 100644 --- a/alacritty/src/config/mod.rs +++ b/alacritty/src/config/mod.rs @@ -7,7 +7,7 @@ use serde::Deserialize; use serde_yaml::mapping::Mapping; use serde_yaml::Value; -use alacritty_terminal::config::{Config as TermConfig, LOG_TARGET_CONFIG}; +use alacritty_terminal::config::LOG_TARGET_CONFIG; pub mod bell; pub mod color; @@ -27,13 +27,11 @@ pub use crate::config::bindings::{ }; #[cfg(test)] pub use crate::config::mouse::{ClickHandler, Mouse}; -use crate::config::ui_config::UiConfig; +pub use crate::config::ui_config::UiConfig; /// Maximum number of depth for the configuration file imports. const IMPORT_RECURSION_LIMIT: usize = 5; -pub type Config = TermConfig<UiConfig>; - /// Result from config loading. pub type Result<T> = std::result::Result<T, Error>; @@ -100,7 +98,7 @@ impl From<serde_yaml::Error> for Error { } /// Load the configuration file. -pub fn load(options: &Options) -> Config { +pub fn load(options: &Options) -> UiConfig { let config_options = options.config_options.clone(); let config_path = options.config_file.clone().or_else(installed_config); @@ -112,9 +110,9 @@ pub fn load(options: &Options) -> Config { .as_ref() .and_then(|config_path| load_from(config_path, config_options.clone()).ok()) .unwrap_or_else(|| { - let mut config = Config::deserialize(config_options).unwrap_or_default(); + let mut config = UiConfig::deserialize(config_options).unwrap_or_default(); match config_path { - Some(config_path) => config.ui_config.config_paths.push(config_path), + Some(config_path) => config.config_paths.push(config_path), None => info!(target: LOG_TARGET_CONFIG, "No config file found; using default"), } config @@ -126,7 +124,7 @@ pub fn load(options: &Options) -> Config { } /// Attempt to reload the configuration file. -pub fn reload(config_path: &Path, options: &Options) -> Result<Config> { +pub fn reload(config_path: &Path, options: &Options) -> Result<UiConfig> { // Load config, propagating errors. let config_options = options.config_options.clone(); let mut config = load_from(config_path, config_options)?; @@ -136,17 +134,17 @@ pub fn reload(config_path: &Path, options: &Options) -> Result<Config> { Ok(config) } -/// Modifications after the `Config` object is created. -fn after_loading(config: &mut Config, options: &Options) { +/// Modifications after the `UiConfig` object is created. +fn after_loading(config: &mut UiConfig, options: &Options) { // Override config with CLI options. options.override_config(config); // Create key bindings for regex hints. - config.ui_config.generate_hint_bindings(); + config.generate_hint_bindings(); } /// Load configuration file and log errors. -fn load_from(path: &Path, cli_config: Value) -> Result<Config> { +fn load_from(path: &Path, cli_config: Value) -> Result<UiConfig> { match read_config(path, cli_config) { Ok(config) => Ok(config), Err(err) => { @@ -157,7 +155,7 @@ fn load_from(path: &Path, cli_config: Value) -> Result<Config> { } /// Deserialize configuration file from path. -fn read_config(path: &Path, cli_config: Value) -> Result<Config> { +fn read_config(path: &Path, cli_config: Value) -> Result<UiConfig> { let mut config_paths = Vec::new(); let mut config_value = parse_config(path, &mut config_paths, IMPORT_RECURSION_LIMIT)?; @@ -165,8 +163,8 @@ fn read_config(path: &Path, cli_config: Value) -> Result<Config> { config_value = serde_utils::merge(config_value, cli_config); // Deserialize to concrete type. - let mut config = Config::deserialize(config_value)?; - config.ui_config.config_paths = config_paths; + let mut config = UiConfig::deserialize(config_value)?; + config.config_paths = config_paths; Ok(config) } @@ -307,7 +305,7 @@ mod tests { fn config_read_eof() { let config_path: PathBuf = DEFAULT_ALACRITTY_CONFIG.into(); let mut config = read_config(&config_path, Value::Null).unwrap(); - config.ui_config.config_paths = Vec::new(); - assert_eq!(config, Config::default()); + config.config_paths = Vec::new(); + assert_eq!(config, UiConfig::default()); } } |