From ead1edc7191f101986cedebbea3e08ce94939196 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sat, 26 Mar 2022 20:36:41 +0800 Subject: [PATCH] KeyHandler // Add Alt-key Punctuation Support. --- Source/Modules/ControllerModules/KeyHandler.mm | 12 ++++++++---- Source/Modules/ControllerModules/KeyParser.swift | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 7ead8929..5414dd3c 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -272,7 +272,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; } // if the composing buffer is empty and there's no reading, and there is some function key combination, we ignore it - BOOL isFunctionKey = ([input isCommandHold] || [input isOptionHold] || [input isNumericPad]) || [input isControlHotKey]; + BOOL isFunctionKey = ([input isCommandHold] || [input isOptionHotKey] || [input isNumericPad]) || [input isControlHotKey]; if (![state isKindOfClass:[InputStateNotEmpty class]] && ![state isKindOfClass:[InputStateAssociatedPhrases class]] && isFunctionKey) { @@ -345,7 +345,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; } bool composeReading = false; - BOOL skipBpmfHandling = [input isReservedKey] || [input isControlHold]; + BOOL skipBpmfHandling = [input isReservedKey] || [input isControlHold] || [input isOptionHold]; // MARK: Handle BPMF Keys @@ -562,7 +562,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; // if nothing is matched, see if it's a punctuation key for current layout. std::string punctuationNamePrefix; - if ([input isControlHold]) { + if ([input isOptionHold]) { + punctuationNamePrefix = std::string("_alt_punctuation_"); + } else if ([input isControlHold]) { punctuationNamePrefix = std::string("_ctrl_punctuation_"); } else if (mgrPrefs.halfWidthPunctuationEnabled) { punctuationNamePrefix = std::string("_half_punctuation_"); @@ -1239,7 +1241,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; if (mgrPrefs.useSCPCTypingMode) { std::string layout = [self _currentLayout]; std::string punctuationNamePrefix; - if ([input isControlHold]) { + if ([input isOptionHold]) { + punctuationNamePrefix = std::string("_alt_punctuation_"); + } else if ([input isControlHold]) { punctuationNamePrefix = std::string("_ctrl_punctuation_"); } else if (mgrPrefs.halfWidthPunctuationEnabled) { punctuationNamePrefix = std::string("_half_punctuation_"); diff --git a/Source/Modules/ControllerModules/KeyParser.swift b/Source/Modules/ControllerModules/KeyParser.swift index 607874dc..36054d5e 100644 --- a/Source/Modules/ControllerModules/KeyParser.swift +++ b/Source/Modules/ControllerModules/KeyParser.swift @@ -134,6 +134,10 @@ class keyParser: NSObject { flags.contains([.control]) && inputText?.first?.isLetter ?? false } + @objc var isOptionHotKey: Bool { + flags.contains([.option]) && inputText?.first?.isLetter ?? false + } + @objc var isOptionHold: Bool { flags.contains([.option]) }