Tekkon // hasToneMarker() -> hasIntonation().
This commit is contained in:
parent
77f071eef5
commit
a9c02f9904
|
@ -210,7 +210,7 @@ if !skipPhoneticHandling && _composer.inputValidityCheck(key: charCode) {
|
||||||
// update the composing buffer.
|
// update the composing buffer.
|
||||||
// 沒有調號的話,只需要 updateClientComposingBuffer() 且終止處理(return true)即可。
|
// 沒有調號的話,只需要 updateClientComposingBuffer() 且終止處理(return true)即可。
|
||||||
// 有調號的話,則不需要這樣處理,轉而繼續在此之後的處理。
|
// 有調號的話,則不需要這樣處理,轉而繼續在此之後的處理。
|
||||||
let composeReading = _composer.hasToneMarker()
|
let composeReading = _composer.hasIntonation()
|
||||||
if !composeReading {
|
if !composeReading {
|
||||||
delegate.switchState(generateStateOfInputting())
|
delegate.switchState(generateStateOfInputting())
|
||||||
return true
|
return true
|
||||||
|
@ -218,7 +218,7 @@ if !skipPhoneticHandling && _composer.inputValidityCheck(key: charCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 這裡不需要做排他性判斷。
|
// 這裡不需要做排他性判斷。
|
||||||
var composeReading = _composer.hasToneMarker()
|
var composeReading = _composer.hasIntonation()
|
||||||
|
|
||||||
// See if we have composition if Enter/Space is hit and buffer is not empty.
|
// See if we have composition if Enter/Space is hit and buffer is not empty.
|
||||||
// We use "|=" conditioning so that the tone marker key is also taken into account.
|
// We use "|=" conditioning so that the tone marker key is also taken into account.
|
||||||
|
@ -227,7 +227,7 @@ var composeReading = _composer.hasToneMarker()
|
||||||
// 來看看詞庫內到底有沒有對應的讀音索引。這裡用了類似「|=」的判斷處理方式。
|
// 來看看詞庫內到底有沒有對應的讀音索引。這裡用了類似「|=」的判斷處理方式。
|
||||||
composeReading = composeReading || (!_composer.isEmpty && (input.isSpace || input.isEnter))
|
composeReading = composeReading || (!_composer.isEmpty && (input.isSpace || input.isEnter))
|
||||||
if composeReading { // 符合按鍵組合條件
|
if composeReading { // 符合按鍵組合條件
|
||||||
if input.isSpace && !_composer.hasToneMarker() {
|
if input.isSpace && !_composer.hasIntonation() {
|
||||||
_composer.receiveKey(fromString: " ") // 補上空格,否則倚天忘形與許氏排列某些音無法響應不了陰平聲調。
|
_composer.receiveKey(fromString: " ") // 補上空格,否則倚天忘形與許氏排列某些音無法響應不了陰平聲調。
|
||||||
// 某些輸入法使用 OVMandarin 而不是鐵恨引擎,所以不需要這樣補。但鐵恨引擎對所有聲調一視同仁。
|
// 某些輸入法使用 OVMandarin 而不是鐵恨引擎,所以不需要這樣補。但鐵恨引擎對所有聲調一視同仁。
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ extension Tekkon {
|
||||||
/// 用來檢測是否有調號的函式,預設情況下不判定聲調以外的內容的存無。
|
/// 用來檢測是否有調號的函式,預設情況下不判定聲調以外的內容的存無。
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - withNothingElse: 追加判定「槽內是否僅有調號」。
|
/// - withNothingElse: 追加判定「槽內是否僅有調號」。
|
||||||
public func hasToneMarker(withNothingElse: Bool = false) -> Bool {
|
public func hasIntonation(withNothingElse: Bool = false) -> Bool {
|
||||||
if !withNothingElse {
|
if !withNothingElse {
|
||||||
return !intonation.isEmpty
|
return !intonation.isEmpty
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ final class TekkonTestsBasic: XCTestCase {
|
||||||
composer.receiveKey(fromString: "l") // ㄠ
|
composer.receiveKey(fromString: "l") // ㄠ
|
||||||
|
|
||||||
// Testing missing tone markers
|
// Testing missing tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
composer.receiveKey(fromString: "3") // 上聲
|
composer.receiveKey(fromString: "3") // 上聲
|
||||||
|
@ -82,17 +82,17 @@ final class TekkonTestsBasic: XCTestCase {
|
||||||
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄉㄧㄠ")
|
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄉㄧㄠ")
|
||||||
|
|
||||||
// Testing having tone markers
|
// Testing having tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having not-only tone markers
|
// Testing having not-only tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having only tone markers
|
// Testing having only tone markers
|
||||||
composer.clear()
|
composer.clear()
|
||||||
composer.receiveKey(fromString: "3") // 上聲
|
composer.receiveKey(fromString: "3") // 上聲
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing auto phonabet combination fixing process.
|
// Testing auto phonabet combination fixing process.
|
||||||
|
@ -189,7 +189,7 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
composer.receiveKey(fromString: "o")
|
composer.receiveKey(fromString: "o")
|
||||||
|
|
||||||
// Testing missing tone markers
|
// Testing missing tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
composer.receiveKey(fromString: "3") // 上聲
|
composer.receiveKey(fromString: "3") // 上聲
|
||||||
|
@ -210,17 +210,17 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄉㄧㄠ")
|
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄉㄧㄠ")
|
||||||
|
|
||||||
// Testing having tone markers
|
// Testing having tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having not-only tone markers
|
// Testing having not-only tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having only tone markers
|
// Testing having only tone markers
|
||||||
composer.clear()
|
composer.clear()
|
||||||
composer.receiveKey(fromString: "3") // 上聲
|
composer.receiveKey(fromString: "3") // 上聲
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
composer.receiveKey(fromString: "g")
|
composer.receiveKey(fromString: "g")
|
||||||
|
|
||||||
// Testing missing tone markers
|
// Testing missing tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
composer.receiveKey(fromString: "2") // 陽平
|
composer.receiveKey(fromString: "2") // 陽平
|
||||||
|
@ -258,17 +258,17 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ")
|
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ")
|
||||||
|
|
||||||
// Testing having tone markers
|
// Testing having tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having not-only tone markers
|
// Testing having not-only tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having only tone markers
|
// Testing having only tone markers
|
||||||
composer.clear()
|
composer.clear()
|
||||||
composer.receiveKey(fromString: "3") // 上聲
|
composer.receiveKey(fromString: "3") // 上聲
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
composer.receiveKey(fromString: "g")
|
composer.receiveKey(fromString: "g")
|
||||||
|
|
||||||
// Testing missing tone markers
|
// Testing missing tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
composer.receiveKey(fromString: "2") // 陽平
|
composer.receiveKey(fromString: "2") // 陽平
|
||||||
|
@ -306,17 +306,17 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ")
|
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ")
|
||||||
|
|
||||||
// Testing having tone markers
|
// Testing having tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having not-only tone markers
|
// Testing having not-only tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having only tone markers
|
// Testing having only tone markers
|
||||||
composer.clear()
|
composer.clear()
|
||||||
composer.receiveKey(fromString: "3") // 上聲
|
composer.receiveKey(fromString: "3") // 上聲
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
composer.receiveKey(fromString: "g")
|
composer.receiveKey(fromString: "g")
|
||||||
|
|
||||||
// Testing missing tone markers
|
// Testing missing tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
composer.receiveKey(fromString: "2") // 陽平
|
composer.receiveKey(fromString: "2") // 陽平
|
||||||
|
@ -354,17 +354,17 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ")
|
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ")
|
||||||
|
|
||||||
// Testing having tone markers
|
// Testing having tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having not-only tone markers
|
// Testing having not-only tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having only tone markers
|
// Testing having only tone markers
|
||||||
composer.clear()
|
composer.clear()
|
||||||
composer.receiveKey(fromString: "3") // 上聲
|
composer.receiveKey(fromString: "3") // 上聲
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
composer.receiveKey(fromString: "g")
|
composer.receiveKey(fromString: "g")
|
||||||
|
|
||||||
// Testing missing tone markers
|
// Testing missing tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
composer.receiveKey(fromString: "2") // 陽平
|
composer.receiveKey(fromString: "2") // 陽平
|
||||||
|
@ -401,17 +401,17 @@ final class TekkonTestsPinyin: XCTestCase {
|
||||||
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ")
|
XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ")
|
||||||
|
|
||||||
// Testing having tone markers
|
// Testing having tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker()
|
toneMarkerIndicator = composer.hasIntonation()
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having not-only tone markers
|
// Testing having not-only tone markers
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(!toneMarkerIndicator)
|
XCTAssert(!toneMarkerIndicator)
|
||||||
|
|
||||||
// Testing having only tone markers
|
// Testing having only tone markers
|
||||||
composer.clear()
|
composer.clear()
|
||||||
composer.receiveKey(fromString: "3") // 上聲
|
composer.receiveKey(fromString: "3") // 上聲
|
||||||
toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true)
|
toneMarkerIndicator = composer.hasIntonation(withNothingElse: true)
|
||||||
XCTAssert(toneMarkerIndicator)
|
XCTAssert(toneMarkerIndicator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,7 +387,7 @@ public class InputHandler: InputHandlerProtocol {
|
||||||
var theComposer = composer // 複製一份用來做實驗。
|
var theComposer = composer // 複製一份用來做實驗。
|
||||||
theComposer.clear() // 清空各種槽的內容。
|
theComposer.clear() // 清空各種槽的內容。
|
||||||
theComposer.receiveKey(fromString: input.text)
|
theComposer.receiveKey(fromString: input.text)
|
||||||
return theComposer.hasToneMarker(withNothingElse: true)
|
return theComposer.hasIntonation(withNothingElse: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Extracted methods and functions (Megrez).
|
// MARK: - Extracted methods and functions (Megrez).
|
||||||
|
|
|
@ -68,19 +68,19 @@ extension InputHandler {
|
||||||
|
|
||||||
// 沒有調號的話,只需要 setInlineDisplayWithCursor() 且終止處理(return true)即可。
|
// 沒有調號的話,只需要 setInlineDisplayWithCursor() 且終止處理(return true)即可。
|
||||||
// 有調號的話,則不需要這樣,而是轉而繼續在此之後的處理。
|
// 有調號的話,則不需要這樣,而是轉而繼續在此之後的處理。
|
||||||
if !composer.hasToneMarker() {
|
if !composer.hasIntonation() {
|
||||||
delegate.switchState(generateStateOfInputting())
|
delegate.switchState(generateStateOfInputting())
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var composeReading = composer.hasToneMarker() && composer.inputValidityCheck(key: input.charCode) // 這裡不需要做排他性判斷。
|
var composeReading = composer.hasIntonation() && composer.inputValidityCheck(key: input.charCode) // 這裡不需要做排他性判斷。
|
||||||
|
|
||||||
// 如果當前的按鍵是 Enter 或 Space 的話,這時就可以取出 _composer 內的注音來做檢查了。
|
// 如果當前的按鍵是 Enter 或 Space 的話,這時就可以取出 _composer 內的注音來做檢查了。
|
||||||
// 來看看詞庫內到底有沒有對應的讀音索引。這裡用了類似「|=」的判斷處理方式。
|
// 來看看詞庫內到底有沒有對應的讀音索引。這裡用了類似「|=」的判斷處理方式。
|
||||||
composeReading = composeReading || (!composer.isEmpty && (input.isSpace || input.isEnter))
|
composeReading = composeReading || (!composer.isEmpty && (input.isSpace || input.isEnter))
|
||||||
if composeReading {
|
if composeReading {
|
||||||
if input.isSpace, !composer.hasToneMarker() {
|
if input.isSpace, !composer.hasIntonation() {
|
||||||
// 補上空格,否則倚天忘形與許氏排列某些音無法響應不了陰平聲調。
|
// 補上空格,否則倚天忘形與許氏排列某些音無法響應不了陰平聲調。
|
||||||
// 小麥注音因為使用 OVMandarin,所以不需要這樣補。但鐵恨引擎對所有聲調一視同仁。
|
// 小麥注音因為使用 OVMandarin,所以不需要這樣補。但鐵恨引擎對所有聲調一視同仁。
|
||||||
composer.receiveKey(fromString: " ")
|
composer.receiveKey(fromString: " ")
|
||||||
|
|
|
@ -360,7 +360,7 @@ extension InputHandler {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if composer.hasToneMarker(withNothingElse: true) {
|
if composer.hasIntonation(withNothingElse: true) {
|
||||||
composer.clear()
|
composer.clear()
|
||||||
} else if composer.isEmpty {
|
} else if composer.isEmpty {
|
||||||
if compositor.cursor > 0 {
|
if compositor.cursor > 0 {
|
||||||
|
|
Loading…
Reference in New Issue