Revert "chore: 使用されていないAPIを削除"

This reverts commit bccb5e48e4.
This commit is contained in:
Miwa / Ensan
2024-08-23 00:13:07 +09:00
parent 87f207eb93
commit af3e2dd2f4

View File

@ -394,6 +394,50 @@ extension ComposingText {
return false
}
// MARK: API
static func isLeftSideValid(first firstElement: InputElement, of originalElements: [InputElement], from leftIndex: Int) -> Bool {
// leftIndex`el`
//
// * leftIndex == startIndex
// * el:direct
// * (_:direct) -> el
// * (a|i|u|e|o:roman2kana) -> el // akaka
// * (e-1:roman2kana and not n) && e-1 == es // ttatanna
// * (n:roman2kana) -> el && el not a|i|u|e|o|y|n // nkakanna
if leftIndex < originalElements.startIndex {
return false
}
// directElement
guard leftIndex != originalElements.startIndex && firstElement.inputStyle == .roman2kana else {
return true
}
let prevLastElement = originalElements[leftIndex - 1]
if prevLastElement.inputStyle != .roman2kana || !CharacterUtils.isRomanLetter(prevLastElement.character) {
return true
}
if ["a", "i", "u", "e", "o"].contains(prevLastElement.character) {
return true
}
if prevLastElement.character != "n" && prevLastElement.character == firstElement.character {
return true
}
let last_2 = originalElements[0 ..< leftIndex].suffix(2)
if ["zl", "zk", "zj", "zh"].contains(last_2.reduce(into: "") {$0.append($1.character)}) {
return true
}
let n_suffix = originalElements[0 ..< leftIndex].suffix(while: {$0.inputStyle == .roman2kana && $0.character == "n"})
if n_suffix.count % 2 == 0 && !n_suffix.isEmpty {
return true
}
if n_suffix.count % 2 == 1 && !["a", "i", "u", "e", "o", "y", "n"].contains(firstElement.character) {
return true
}
return false
}
/// valid調
/// - Parameters:
/// - lastElement: