From e066ad4e7a20ade44bbdaacf16f20f6bd804b047 Mon Sep 17 00:00:00 2001 From: Seungheon Oh Date: Sat, 19 Nov 2022 20:49:47 -0600 Subject: [PATCH] add translation layer support for `kime-check` --- src/tools/check/src/main.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/tools/check/src/main.rs b/src/tools/check/src/main.rs index 31fb5a60..54815a14 100644 --- a/src/tools/check/src/main.rs +++ b/src/tools/check/src/main.rs @@ -1,3 +1,5 @@ +use kime_engine_core::{Key, KeyMap}; + use ansi_term::Color; use kime_engine_cffi::{ Config, InputCategory, InputEngine, InputResult_CONSUMED, InputResult_HAS_COMMIT, @@ -133,6 +135,33 @@ impl Check { } }; + match _config.engine.translation_layer { + Some(ref raw_path) => { + let path = match dirs.find_config_file(raw_path) { + Some(path) => path, + _ => { + return CondResult::Ignore( + "translation layer configuration does not exist. No translation layer will be used".into()) + } + }; + println!("Loading translation layer config: {}", path.display()); + + let _translation_layer: KeyMap = match serde_yaml::from_str( + &std::fs::read_to_string(path.as_path()) + .expect("Read translation layer config"), + ) { + Ok(c) => c, + Err(err) => { + return CondResult::Fail(format!( + "Can't parse {:#?}: {}", + path, err + )) + } + }; + } + None => return CondResult::Ok, + }; + // TODO: check layout CondResult::Ok