ctlIME & KeyHandler // Add ObjC way to know current inputMode.

- This is not recommended to use unless in rare cases that the ctlInputMethod.currentKeyHandler approach doesn't work.
This commit is contained in:
ShikiSuen 2022-03-10 15:16:52 +08:00
parent 524ada5a5e
commit d4f6c7c52e
2 changed files with 11 additions and 3 deletions

View File

@ -27,9 +27,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#import "vChewing-Swift.h"
#import <string>
InputMode imeModeCHT = @"org.atelierInmu.inputmethod.vChewing.IMECHT";
InputMode imeModeCHS = @"org.atelierInmu.inputmethod.vChewing.IMECHS";
InputMode imeModeNULL = @"org.atelierInmu.inputmethod.vChewing.IMENULL";
InputMode imeModeCHS = ctlInputMethod.kIMEModeCHS;
InputMode imeModeCHT = ctlInputMethod.kIMEModeCHT;
InputMode imeModeNULL = ctlInputMethod.kIMEModeNULL;
static const double kEpsilon = 0.000001;
@ -111,6 +111,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
newUserOverrideModel = [mgrLangModel userOverrideModelCHT];
}
// Report the current Input Mode to ctlInputMethod:
ctlInputMethod.currentInputMode = newInputMode;
// Synchronize the Preference Setting "setPhraseReplacementEnabled" to the new LM.
newLanguageModel->setPhraseReplacementEnabled(Preferences.phraseReplacementEnabled);

View File

@ -38,6 +38,10 @@ private extension CandidateController {
@objc(ctlInputMethod)
class ctlInputMethod: IMKInputController {
@objc static let kIMEModeCHS = "org.atelierInmu.inputmethod.vChewing.IMECHS";
@objc static let kIMEModeCHT = "org.atelierInmu.inputmethod.vChewing.IMECHT";
@objc static let kIMEModeNULL = "org.atelierInmu.inputmethod.vChewing.IMENULL";
private static let tooltipController = TooltipController()
// MARK: -
@ -53,6 +57,7 @@ class ctlInputMethod: IMKInputController {
// currentKeyHandler keyHandler
// currentKeyHandler
static var currentKeyHandler: KeyHandler = KeyHandler()
@objc static var currentInputMode = ""
// MARK: - IMKInputController methods