LMInstantiator // Add cassetteSymbolDataFor().
This commit is contained in:
parent
7a76cc89d2
commit
cfdd6fdc1b
|
@ -11,13 +11,13 @@ import Megrez
|
||||||
import Shared
|
import Shared
|
||||||
|
|
||||||
public extension vChewingLM.LMInstantiator {
|
public extension vChewingLM.LMInstantiator {
|
||||||
/// 當前磁帶所規定的花牌鍵。
|
/// 磁帶模式專用:當前磁帶所規定的花牌鍵。
|
||||||
var cassetteWildcardKey: String { Self.lmCassette.wildcardKey }
|
var cassetteWildcardKey: String { Self.lmCassette.wildcardKey }
|
||||||
/// 當前磁帶規定的最大碼長。
|
/// 磁帶模式專用:當前磁帶規定的最大碼長。
|
||||||
var maxCassetteKeyLength: Int { Self.lmCassette.maxKeyLength }
|
var maxCassetteKeyLength: Int { Self.lmCassette.maxKeyLength }
|
||||||
/// 磁帶模式專用函式:指定 `%quick` 快速候選結果當中要過濾掉的無效候選字符號。
|
/// 磁帶模式專用:指定 `%quick` 快速候選結果當中要過濾掉的無效候選字符號。
|
||||||
var nullCandidateInCassette: String { Self.lmCassette.nullCandidate }
|
var nullCandidateInCassette: String { Self.lmCassette.nullCandidate }
|
||||||
/// 選字鍵,在威注音輸入法當中僅優先用於快速模式。
|
/// 磁帶模式專用:選字鍵,在威注音輸入法當中僅優先用於快速模式。
|
||||||
var cassetteSelectionKey: String? {
|
var cassetteSelectionKey: String? {
|
||||||
let result = Self.lmCassette.selectionKeys
|
let result = Self.lmCassette.selectionKeys
|
||||||
return result.isEmpty ? nil : result
|
return result.isEmpty ? nil : result
|
||||||
|
@ -30,28 +30,37 @@ public extension vChewingLM.LMInstantiator {
|
||||||
Self.lmCassette.quickSetsFor(key: key)
|
Self.lmCassette.quickSetsFor(key: key)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 將當前的按鍵轉換成磁帶內定義了的字根。
|
/// 磁帶模式專用函式:調取 `%symboldata` 符號選單查詢結果。
|
||||||
|
/// - Parameter key: 按鍵字元。
|
||||||
|
/// - Returns: 結果。
|
||||||
|
func cassetteSymbolDataFor(key: String) -> [String]? {
|
||||||
|
guard let fetched = Self.lmCassette.symbolDefMap[key] else { return nil }
|
||||||
|
guard !fetched.joined().isEmpty else { return nil }
|
||||||
|
return fetched
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 磁帶模式專用函式:將當前的按鍵轉換成磁帶內定義了的字根。
|
||||||
/// - Parameter char: 按鍵字元。
|
/// - Parameter char: 按鍵字元。
|
||||||
/// - Returns: 轉換結果。如果轉換失敗,則返回原始按鍵字元。
|
/// - Returns: 轉換結果。如果轉換失敗,則返回原始按鍵字元。
|
||||||
func convertCassetteKeyToDisplay(char: String) -> String {
|
func convertCassetteKeyToDisplay(char: String) -> String {
|
||||||
Self.lmCassette.convertKeyToDisplay(char: char)
|
Self.lmCassette.convertKeyToDisplay(char: char)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 檢查當前的按鍵是否屬於目前的磁帶規定的允許的字根按鍵。
|
/// 磁帶模式專用函式:檢查當前的按鍵是否屬於目前的磁帶規定的允許的字根按鍵。
|
||||||
/// - Parameter key: 按鍵字元。
|
/// - Parameter key: 按鍵字元。
|
||||||
/// - Returns: 檢查結果。
|
/// - Returns: 檢查結果。
|
||||||
func isThisCassetteKeyAllowed(key: String) -> Bool {
|
func isThisCassetteKeyAllowed(key: String) -> Bool {
|
||||||
Self.lmCassette.allowedKeys.contains(key)
|
Self.lmCassette.allowedKeys.contains(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 檢查給定的索引鍵在搭上花牌鍵之後是否有匹配結果。
|
/// 磁帶模式專用函式:檢查給定的索引鍵在搭上花牌鍵之後是否有匹配結果。
|
||||||
/// - Parameter key: 給定的索引鍵。
|
/// - Parameter key: 給定的索引鍵。
|
||||||
/// - Returns: 是否有批配結果。
|
/// - Returns: 是否有批配結果。
|
||||||
func hasCassetteWildcardResultsFor(key: String) -> Bool {
|
func hasCassetteWildcardResultsFor(key: String) -> Bool {
|
||||||
Self.lmCassette.hasUnigramsFor(key: key + Self.lmCassette.wildcard)
|
Self.lmCassette.hasUnigramsFor(key: key + Self.lmCassette.wildcard)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 提供磁帶反查結果。
|
/// 磁帶模式專用函式:提供磁帶反查結果。
|
||||||
/// - Parameter value: 要拿來反查的字詞。
|
/// - Parameter value: 要拿來反查的字詞。
|
||||||
/// - Returns: 反查結果字串陣列。
|
/// - Returns: 反查結果字串陣列。
|
||||||
func cassetteReverseLookup(for value: String) -> [String] {
|
func cassetteReverseLookup(for value: String) -> [String] {
|
||||||
|
|
Loading…
Reference in New Issue