diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-01-09 17:56:40 -0500 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-01-09 17:56:40 -0500 |
commit | 61dc86ffb00ee705bdd4bacefe375d5ff28d6517 (patch) | |
tree | 9b995bfa89dc53d34d9ae7dc039c0d686d5f9567 /src/config/keymap | |
parent | e428cf22dd1f5f735c5b51ab03986b700201dfa4 (diff) |
default configuration for joshuto and for themes now read from
the default configuration files in repo
Diffstat (limited to 'src/config/keymap')
-rw-r--r-- | src/config/keymap/default_keymap.rs | 5 | ||||
-rw-r--r-- | src/config/keymap/keymapping.rs | 6 | ||||
-rw-r--r-- | src/config/keymap/mod.rs | 7 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/config/keymap/default_keymap.rs b/src/config/keymap/default_keymap.rs deleted file mode 100644 index 281e42d..0000000 --- a/src/config/keymap/default_keymap.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(not(target_os = "windows"))] -pub const DEFAULT_KEYMAP: &str = include_str!("../../../config/keymap.toml"); - -#[cfg(target_os = "windows")] -pub const DEFAULT_KEYMAP: &str = include_str!("..\\..\\..\\config\\keymap.toml"); diff --git a/src/config/keymap/keymapping.rs b/src/config/keymap/keymapping.rs index 5a02178..341db95 100644 --- a/src/config/keymap/keymapping.rs +++ b/src/config/keymap/keymapping.rs @@ -13,7 +13,7 @@ use crate::error::JoshutoResult; use crate::key_command::{Command, CommandKeybind}; use crate::util::keyparse::str_to_event; -use super::default_keymap::DEFAULT_KEYMAP; +use super::DEFAULT_CONFIG_FILE_PATH; #[derive(Debug, Deserialize)] struct CommandKeymap { @@ -40,7 +40,7 @@ impl AppKeyMapping { } pub fn default_res() -> JoshutoResult<Self> { - let crude: AppKeyMappingCrude = toml::from_str(DEFAULT_KEYMAP)?; + let crude: AppKeyMappingCrude = toml::from_str(DEFAULT_CONFIG_FILE_PATH)?; let keymapping: Self = Self::from(crude); Ok(keymapping) } @@ -99,6 +99,8 @@ impl TomlConfigFile for AppKeyMapping { impl std::default::Default for AppKeyMapping { fn default() -> Self { + // This should not fail. + // If it fails then there is a (syntax) error in the default config file AppKeyMapping::default_res().unwrap() } } diff --git a/src/config/keymap/mod.rs b/src/config/keymap/mod.rs index 97e2a33..609f1e6 100644 --- a/src/config/keymap/mod.rs +++ b/src/config/keymap/mod.rs @@ -1,4 +1,9 @@ -mod default_keymap; mod keymapping; pub use self::keymapping::AppKeyMapping; + +#[cfg(not(target_os = "windows"))] +const DEFAULT_CONFIG_FILE_PATH: &str = include_str!("../../../config/keymap.toml"); + +#[cfg(target_os = "windows")] +const DEFAULT_CONFIG_FILE_PATH: &str = include_str!("..\\..\\..\\config\\keymap.toml"); |