kime
kime copied to clipboard
한글모드에서 특수기호 단축키가 작동하지 않는 경우
@,# 같은 특수기호로 작동하는 단축키가 한글모드에서 작동하지 않는 경우가 있습니다. ime에서는 preedit과정에서 keydown 이벤트가 발생하지않고 조합이 완료된 후에 input이벤트를 발생시키는데 keydown 이벤트가 단축키 트리거로 작동하는 경우 input만 주어지게되어 단축키가 작동하지 않습니다 조합이 필요없는 특수문자가 입력되면 현재 preedit을 종료하고 특수문자는 바로 bypass시키면 keydown이벤트가 작동해서 문제가 해결됩니다.
--- a/src/engine/backends/hangul/src/state.rs
+++ b/src/engine/backends/hangul/src/state.rs
@@ -14,6 +14,11 @@ pub struct HangulEngine {
word_buf: String,
}
+const SPECIAL_CHARS: &[char] = &[
+ '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', '[', ']', '{', '}', ';',
+ ':', '\'', '"', ',', '<', '.', '>', '/', '?', '\\', '|', '`', '~',
+];
+
impl HangulEngine {
pub fn new(word_commit: bool, preedit_johab: PreeditJohabLevel) -> Self {
Self {
@@ -73,9 +78,16 @@ impl HangulEngine {
pub fn key(&mut self, kv: KeyValue, addons: EnumSet<Addon>, commit_buf: &mut String) -> bool {
let ret = match kv {
KeyValue::Pass(pass) => {
- self.clear_preedit(commit_buf);
- commit_buf.push(pass);
- return true;
+ if SPECIAL_CHARS.contains(&pass) {
+ if self.has_preedit() {
+ self.clear_preedit(commit_buf);
+ }
+ return false;
+ } else {
+ self.clear_preedit(commit_buf);
+ commit_buf.push(pass);
+ return true;
+ }
}
KeyValue::Choseong { cho } => self.state.cho(cho, addons),
KeyValue::Jungseong { jung, compose } => self.state.jung(jung, compose, addons),
아얘 전부 false를 리턴하는것도 좋을것 같네요