From a9c02f9904b23e03fcec12fa2a260c9832c05be2 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 17 Oct 2022 10:01:48 +0800 Subject: [PATCH] Tekkon // hasToneMarker() -> hasIntonation(). --- Packages/vChewing_Tekkon/README.md | 6 +-- .../Tekkon/Tekkon_SyllableComposer.swift | 2 +- .../Tests/TekkonTests/BasicTests.swift | 48 +++++++++---------- Source/Modules/InputHandler_Core.swift | 2 +- .../InputHandler_HandleComposition.swift | 6 +-- Source/Modules/InputHandler_States.swift | 2 +- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Packages/vChewing_Tekkon/README.md b/Packages/vChewing_Tekkon/README.md index c04a0a84..0f373ffb 100644 --- a/Packages/vChewing_Tekkon/README.md +++ b/Packages/vChewing_Tekkon/README.md @@ -210,7 +210,7 @@ if !skipPhoneticHandling && _composer.inputValidityCheck(key: charCode) { // update the composing buffer. // 沒有調號的話,只需要 updateClientComposingBuffer() 且終止處理(return true)即可。 // 有調號的話,則不需要這樣處理,轉而繼續在此之後的處理。 - let composeReading = _composer.hasToneMarker() + let composeReading = _composer.hasIntonation() if !composeReading { delegate.switchState(generateStateOfInputting()) 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. // 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)) if composeReading { // 符合按鍵組合條件 - if input.isSpace && !_composer.hasToneMarker() { + if input.isSpace && !_composer.hasIntonation() { _composer.receiveKey(fromString: " ") // 補上空格,否則倚天忘形與許氏排列某些音無法響應不了陰平聲調。 // 某些輸入法使用 OVMandarin 而不是鐵恨引擎,所以不需要這樣補。但鐵恨引擎對所有聲調一視同仁。 } diff --git a/Packages/vChewing_Tekkon/Sources/Tekkon/Tekkon_SyllableComposer.swift b/Packages/vChewing_Tekkon/Sources/Tekkon/Tekkon_SyllableComposer.swift index 993d8dde..4c1abc11 100644 --- a/Packages/vChewing_Tekkon/Sources/Tekkon/Tekkon_SyllableComposer.swift +++ b/Packages/vChewing_Tekkon/Sources/Tekkon/Tekkon_SyllableComposer.swift @@ -317,7 +317,7 @@ extension Tekkon { /// 用來檢測是否有調號的函式,預設情況下不判定聲調以外的內容的存無。 /// - Parameters: /// - withNothingElse: 追加判定「槽內是否僅有調號」。 - public func hasToneMarker(withNothingElse: Bool = false) -> Bool { + public func hasIntonation(withNothingElse: Bool = false) -> Bool { if !withNothingElse { return !intonation.isEmpty } diff --git a/Packages/vChewing_Tekkon/Tests/TekkonTests/BasicTests.swift b/Packages/vChewing_Tekkon/Tests/TekkonTests/BasicTests.swift index d578f1b5..ddd32670 100644 --- a/Packages/vChewing_Tekkon/Tests/TekkonTests/BasicTests.swift +++ b/Packages/vChewing_Tekkon/Tests/TekkonTests/BasicTests.swift @@ -61,7 +61,7 @@ final class TekkonTestsBasic: XCTestCase { composer.receiveKey(fromString: "l") // ㄠ // Testing missing tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(!toneMarkerIndicator) composer.receiveKey(fromString: "3") // 上聲 @@ -82,17 +82,17 @@ final class TekkonTestsBasic: XCTestCase { XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄉㄧㄠ") // Testing having tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(toneMarkerIndicator) // Testing having not-only tone markers - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(!toneMarkerIndicator) // Testing having only tone markers composer.clear() composer.receiveKey(fromString: "3") // 上聲 - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(toneMarkerIndicator) // Testing auto phonabet combination fixing process. @@ -189,7 +189,7 @@ final class TekkonTestsPinyin: XCTestCase { composer.receiveKey(fromString: "o") // Testing missing tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(!toneMarkerIndicator) composer.receiveKey(fromString: "3") // 上聲 @@ -210,17 +210,17 @@ final class TekkonTestsPinyin: XCTestCase { XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄉㄧㄠ") // Testing having tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(toneMarkerIndicator) // Testing having not-only tone markers - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(!toneMarkerIndicator) // Testing having only tone markers composer.clear() composer.receiveKey(fromString: "3") // 上聲 - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(toneMarkerIndicator) } @@ -237,7 +237,7 @@ final class TekkonTestsPinyin: XCTestCase { composer.receiveKey(fromString: "g") // Testing missing tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(!toneMarkerIndicator) composer.receiveKey(fromString: "2") // 陽平 @@ -258,17 +258,17 @@ final class TekkonTestsPinyin: XCTestCase { XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ") // Testing having tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(toneMarkerIndicator) // Testing having not-only tone markers - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(!toneMarkerIndicator) // Testing having only tone markers composer.clear() composer.receiveKey(fromString: "3") // 上聲 - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(toneMarkerIndicator) } @@ -285,7 +285,7 @@ final class TekkonTestsPinyin: XCTestCase { composer.receiveKey(fromString: "g") // Testing missing tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(!toneMarkerIndicator) composer.receiveKey(fromString: "2") // 陽平 @@ -306,17 +306,17 @@ final class TekkonTestsPinyin: XCTestCase { XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ") // Testing having tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(toneMarkerIndicator) // Testing having not-only tone markers - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(!toneMarkerIndicator) // Testing having only tone markers composer.clear() composer.receiveKey(fromString: "3") // 上聲 - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(toneMarkerIndicator) } @@ -333,7 +333,7 @@ final class TekkonTestsPinyin: XCTestCase { composer.receiveKey(fromString: "g") // Testing missing tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(!toneMarkerIndicator) composer.receiveKey(fromString: "2") // 陽平 @@ -354,17 +354,17 @@ final class TekkonTestsPinyin: XCTestCase { XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ") // Testing having tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(toneMarkerIndicator) // Testing having not-only tone markers - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(!toneMarkerIndicator) // Testing having only tone markers composer.clear() composer.receiveKey(fromString: "3") // 上聲 - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(toneMarkerIndicator) } @@ -380,7 +380,7 @@ final class TekkonTestsPinyin: XCTestCase { composer.receiveKey(fromString: "g") // Testing missing tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(!toneMarkerIndicator) composer.receiveKey(fromString: "2") // 陽平 @@ -401,17 +401,17 @@ final class TekkonTestsPinyin: XCTestCase { XCTAssertEqual(composer.getComposition(isTextBookStyle: true), "˙ㄑㄩㄥ") // Testing having tone markers - toneMarkerIndicator = composer.hasToneMarker() + toneMarkerIndicator = composer.hasIntonation() XCTAssert(toneMarkerIndicator) // Testing having not-only tone markers - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(!toneMarkerIndicator) // Testing having only tone markers composer.clear() composer.receiveKey(fromString: "3") // 上聲 - toneMarkerIndicator = composer.hasToneMarker(withNothingElse: true) + toneMarkerIndicator = composer.hasIntonation(withNothingElse: true) XCTAssert(toneMarkerIndicator) } } diff --git a/Source/Modules/InputHandler_Core.swift b/Source/Modules/InputHandler_Core.swift index 7fe92f22..62cef7ce 100644 --- a/Source/Modules/InputHandler_Core.swift +++ b/Source/Modules/InputHandler_Core.swift @@ -387,7 +387,7 @@ public class InputHandler: InputHandlerProtocol { var theComposer = composer // 複製一份用來做實驗。 theComposer.clear() // 清空各種槽的內容。 theComposer.receiveKey(fromString: input.text) - return theComposer.hasToneMarker(withNothingElse: true) + return theComposer.hasIntonation(withNothingElse: true) } // MARK: - Extracted methods and functions (Megrez). diff --git a/Source/Modules/InputHandler_HandleComposition.swift b/Source/Modules/InputHandler_HandleComposition.swift index 8813f65f..c98ad7ed 100644 --- a/Source/Modules/InputHandler_HandleComposition.swift +++ b/Source/Modules/InputHandler_HandleComposition.swift @@ -68,19 +68,19 @@ extension InputHandler { // 沒有調號的話,只需要 setInlineDisplayWithCursor() 且終止處理(return true)即可。 // 有調號的話,則不需要這樣,而是轉而繼續在此之後的處理。 - if !composer.hasToneMarker() { + if !composer.hasIntonation() { delegate.switchState(generateStateOfInputting()) return true } } - var composeReading = composer.hasToneMarker() && composer.inputValidityCheck(key: input.charCode) // 這裡不需要做排他性判斷。 + var composeReading = composer.hasIntonation() && composer.inputValidityCheck(key: input.charCode) // 這裡不需要做排他性判斷。 // 如果當前的按鍵是 Enter 或 Space 的話,這時就可以取出 _composer 內的注音來做檢查了。 // 來看看詞庫內到底有沒有對應的讀音索引。這裡用了類似「|=」的判斷處理方式。 composeReading = composeReading || (!composer.isEmpty && (input.isSpace || input.isEnter)) if composeReading { - if input.isSpace, !composer.hasToneMarker() { + if input.isSpace, !composer.hasIntonation() { // 補上空格,否則倚天忘形與許氏排列某些音無法響應不了陰平聲調。 // 小麥注音因為使用 OVMandarin,所以不需要這樣補。但鐵恨引擎對所有聲調一視同仁。 composer.receiveKey(fromString: " ") diff --git a/Source/Modules/InputHandler_States.swift b/Source/Modules/InputHandler_States.swift index a14fbfbb..33e60288 100644 --- a/Source/Modules/InputHandler_States.swift +++ b/Source/Modules/InputHandler_States.swift @@ -360,7 +360,7 @@ extension InputHandler { return true } - if composer.hasToneMarker(withNothingElse: true) { + if composer.hasIntonation(withNothingElse: true) { composer.clear() } else if composer.isEmpty { if compositor.cursor > 0 {