Tekkon // hasToneMarker() -> hasIntonation().

This commit is contained in:
ShikiSuen 2022-10-17 10:01:48 +08:00
parent 77f071eef5
commit a9c02f9904
6 changed files with 33 additions and 33 deletions

View File

@ -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 而不是鐵恨引擎,所以不需要這樣補。但鐵恨引擎對所有聲調一視同仁。
}

View File

@ -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
}

View File

@ -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)
}
}

View File

@ -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).

View File

@ -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: " ")

View File

@ -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 {