LMCassette // Add support for `%keys_to_directly_commit`.

This commit is contained in:
ShikiSuen 2023-12-08 00:44:34 +08:00
parent 2a4b01c234
commit 51580ac2fb
2 changed files with 6 additions and 0 deletions

View File

@ -19,6 +19,8 @@ public extension vChewingLM.LMInstantiator {
var nullCandidateInCassette: String { Self.lmCassette.nullCandidate }
/// Shift
var areCassetteCandidateKeysShiftHeld: Bool { Self.lmCassette.areCandidateKeysShiftHeld }
///
var keysToDirectlyCommit: String { Self.lmCassette.keysToDirectlyCommit }
///
var cassetteSelectionKey: String? {
let result = Self.lmCassette.selectionKeys

View File

@ -26,6 +26,7 @@ public extension vChewingLM {
public private(set) var selectionKeys: String = ""
public private(set) var endKeys: [String] = []
public private(set) var wildcardKey: String = ""
public private(set) var keysToDirectlyCommit: String = ""
public private(set) var keyNameMap: [String: String] = [:]
public private(set) var quickDefMap: [String: String] = [:]
public private(set) var charDefMap: [String: [String]] = [:]
@ -208,6 +209,9 @@ public extension vChewingLM {
if wildcardKey.isEmpty, strLine.starts(with: "%wildcardkey ") {
wildcardKey = cells[1].first?.description ?? ""
}
if keysToDirectlyCommit.isEmpty, strLine.starts(with: "%keys_to_directly_commit ") {
keysToDirectlyCommit = strSecondCell
}
}
// Post process.
if CandidateKey.validate(keys: selectionKeys) != nil { selectionKeys = "1234567890" }