aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/input/config.rs
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-05-09 16:44:05 +0200
committera-kenji <aks.kenji@protonmail.com>2021-05-10 16:03:06 +0200
commit088bcf3dd8aab4e522cface84c0a260b5b37a87c (patch)
tree5ed94988521c3caa2eefc00277569345e0f0d8f6 /src/common/input/config.rs
parentREADME: shortening + add explanation (#470) (diff)
downloadsl0ppij-088bcf3dd8aab4e522cface84c0a260b5b37a87c.tar.gz
sl0ppij-088bcf3dd8aab4e522cface84c0a260b5b37a87c.tar.xz
sl0ppij-088bcf3dd8aab4e522cface84c0a260b5b37a87c.zip
Add Option for Simplified Layout
* the simplified layout omits the Nerdfonts characters that are not found in every Fontset * add an optional config option to opt into the simplified ui `simplified_ui: bool` * add a config flag that allows opting into the simplified ui `zellij options --simplified-ui` * move the `clean` flag to the `setup` subcommand
Diffstat (limited to 'src/common/input/config.rs')
-rw-r--r--src/common/input/config.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/common/input/config.rs b/src/common/input/config.rs
index 3263b571..019d1c4c 100644
--- a/src/common/input/config.rs
+++ b/src/common/input/config.rs
@@ -6,10 +6,11 @@ use std::io::{self, Read};
use std::path::{Path, PathBuf};
use super::keybinds::{Keybinds, KeybindsFromYaml};
+use super::options::Options;
use crate::cli::{CliArgs, ConfigCli};
use crate::common::setup;
-use serde::Deserialize;
+use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
const DEFAULT_CONFIG_FILE_NAME: &str = "config.yaml";
@@ -19,13 +20,16 @@ type ConfigResult = Result<Config, ConfigError>;
/// Intermediate deserialization config struct
#[derive(Debug, Deserialize)]
pub struct ConfigFromYaml {
+ #[serde(flatten)]
+ pub options: Option<Options>,
pub keybinds: Option<KeybindsFromYaml>,
}
/// Main configuration.
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct Config {
pub keybinds: Keybinds,
+ pub options: Options,
}
#[derive(Debug)]
@@ -43,7 +47,8 @@ pub enum ConfigError {
impl Default for Config {
fn default() -> Self {
let keybinds = Keybinds::default();
- Config { keybinds }
+ let options = Options::default();
+ Config { keybinds, options }
}
}
@@ -55,7 +60,7 @@ impl TryFrom<&CliArgs> for Config {
return Config::new(&path);
}
- if let Some(ConfigCli::Config { clean, .. }) = opts.option {
+ if let Some(ConfigCli::Setup { clean, .. }) = opts.option {
if clean {
return Config::from_default_assets();
}
@@ -84,7 +89,8 @@ impl Config {
pub fn from_yaml(yaml_config: &str) -> ConfigResult {
let config_from_yaml: ConfigFromYaml = serde_yaml::from_str(&yaml_config)?;
let keybinds = Keybinds::get_default_keybinds_with_config(config_from_yaml.keybinds);
- Ok(Config { keybinds })
+ let options = Options::from_yaml(config_from_yaml.options);
+ Ok(Config { keybinds, options })
}
/// Deserializes from given path.