Updates test cases.
This commit is contained in:
parent
61c4a32f05
commit
cac954a00b
|
@ -21,9 +21,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreEmpty() {
|
func testIgnoreEmpty() {
|
||||||
let input = KeyHandlerInput(inputText: "", keyCode: 0, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "", keyCode: 0, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -32,9 +31,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreEnter() {
|
func testIgnoreEnter() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.enter.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.enter.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -43,9 +41,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreUp() {
|
func testIgnoreUp() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.up.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.up.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result, "\(state)")
|
XCTAssertFalse(result, "\(state)")
|
||||||
|
@ -54,9 +51,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreDown() {
|
func testIgnoreDown() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.down.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.down.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result, "\(state)")
|
XCTAssertFalse(result, "\(state)")
|
||||||
|
@ -65,9 +61,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreLeft() {
|
func testIgnoreLeft() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.left.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.left.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -76,9 +71,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreRight() {
|
func testIgnoreRight() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.right.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.right.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -87,9 +81,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnorePageUp() {
|
func testIgnorePageUp() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.pageUp.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.pageUp.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -98,9 +91,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnorePageDown() {
|
func testIgnorePageDown() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.pageDown.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.pageDown.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -109,9 +101,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreHome() {
|
func testIgnoreHome() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.home.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.home.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -120,9 +111,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreEnd() {
|
func testIgnoreEnd() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.end.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.end.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -131,9 +121,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreDelete() {
|
func testIgnoreDelete() {
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.delete.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.delete.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -142,9 +131,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreCommand() {
|
func testIgnoreCommand() {
|
||||||
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: 0, flags: [.command], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: 0, flags: [.command], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -153,9 +141,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreOption() {
|
func testIgnoreOption() {
|
||||||
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: 0, flags: [.option], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: 0, flags: [.option], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -164,9 +151,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreNumericPad() {
|
func testIgnoreNumericPad() {
|
||||||
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: 0, flags: [.numericPad], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: 0, flags: [.numericPad], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
|
@ -175,22 +161,69 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
func testIgnoreCapslock() {
|
func testIgnoreCapslock() {
|
||||||
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: 0, flags: [.capsLock], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: 0, flags: [.capsLock], isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let result = handler.handle(input, state: state) { newState in
|
let result = handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testisNumericPad() {
|
||||||
|
var input = KeyHandlerInput(inputText: "b", keyCode: 0, charCode: charCode("b"), flags: [], isVerticalMode: false)
|
||||||
|
var state: InputState = InputState.Empty()
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
state = newState
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
input = KeyHandlerInput(inputText: "1", keyCode: 0, charCode: charCode("1"), flags: .numericPad, isVerticalMode: false)
|
||||||
|
var count = 0
|
||||||
|
var empty: InputState = InputState.Empty()
|
||||||
|
var target: InputState = InputState.Empty()
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
switch count {
|
||||||
|
case 0:
|
||||||
|
state = newState
|
||||||
|
case 1:
|
||||||
|
target = newState
|
||||||
|
case 2:
|
||||||
|
empty = newState
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
XCTAssertEqual(count, 3)
|
||||||
|
XCTAssertTrue(state is InputState.Empty, "\(state)")
|
||||||
|
XCTAssertTrue(empty is InputState.Empty, "\(empty)")
|
||||||
|
XCTAssertTrue(target is InputState.Committing, "\(target)")
|
||||||
|
if let state = target as? InputState.Committing {
|
||||||
|
XCTAssertEqual(state.poppedText, "1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testLetter() {
|
||||||
|
let input = KeyHandlerInput(inputText: "A", keyCode: 0, charCode: charCode("A"), flags: .shift, isVerticalMode: false)
|
||||||
|
var state: InputState = InputState.Empty()
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
state = newState
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||||
|
if let state = state as? InputState.Inputting {
|
||||||
|
XCTAssertEqual(state.composingBuffer, "a")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testPunctuationTable() {
|
func testPunctuationTable() {
|
||||||
let enabled = Preferences.halfWidthPunctuationEnabled
|
let enabled = Preferences.halfWidthPunctuationEnabled
|
||||||
Preferences.halfWidthPunctuationEnabled = false
|
Preferences.halfWidthPunctuationEnabled = false
|
||||||
let input = KeyHandlerInput(inputText: "`", keyCode: 0, charCode: charCode("`"), flags: .shift, isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "`", keyCode: 0, charCode: charCode("`"), flags: .shift, isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,9 +239,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
Preferences.halfWidthPunctuationEnabled = true
|
Preferences.halfWidthPunctuationEnabled = true
|
||||||
let input = KeyHandlerInput(inputText: "<", keyCode: 0, charCode: charCode("<"), flags: .shift, isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "<", keyCode: 0, charCode: charCode("<"), flags: .shift, isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,9 +257,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
Preferences.halfWidthPunctuationEnabled = false
|
Preferences.halfWidthPunctuationEnabled = false
|
||||||
let input = KeyHandlerInput(inputText: "<", keyCode: 0, charCode: charCode("<"), flags: .shift, isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "<", keyCode: 0, charCode: charCode("<"), flags: .shift, isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,9 +274,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
Preferences.halfWidthPunctuationEnabled = true
|
Preferences.halfWidthPunctuationEnabled = true
|
||||||
let input = KeyHandlerInput(inputText: ">", keyCode: 0, charCode: charCode(">"), flags: .shift, isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: ">", keyCode: 0, charCode: charCode(">"), flags: .shift, isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,9 +292,26 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
let input = KeyHandlerInput(inputText: ">", keyCode: 0, charCode: charCode(">"), flags: .shift, isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: ">", keyCode: 0, charCode: charCode(">"), flags: .shift, isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
state = newState
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||||
|
if let state = state as? InputState.Inputting {
|
||||||
|
XCTAssertEqual(state.composingBuffer, "。")
|
||||||
|
}
|
||||||
|
Preferences.halfWidthPunctuationEnabled = enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
func testCtrlPunctuationPeriod() {
|
||||||
|
let enabled = Preferences.halfWidthPunctuationEnabled
|
||||||
|
Preferences.halfWidthPunctuationEnabled = false
|
||||||
|
|
||||||
|
let input = KeyHandlerInput(inputText: ".", keyCode: 0, charCode: charCode("."), flags: .control, isVerticalMode: false)
|
||||||
|
var state: InputState = InputState.Empty()
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,12 +324,13 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testInputting() {
|
func testInputting() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("vul3a945j4up gj bj4z83").map { String($0) }
|
let keys = Array("vul3a945j4up gj bj4z83").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,12 +342,13 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testInputtingNihao() {
|
func testInputtingNihao() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3cl3").map { String($0) }
|
let keys = Array("su3cl3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,12 +360,13 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testInputtingTianKong() {
|
func testInputtingTianKong() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("wu0 dj/ ").map { String($0) }
|
let keys = Array("wu0 dj/ ").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,12 +378,13 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testCommittingNihao() {
|
func testCommittingNihao() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3cl3").map { String($0) }
|
let keys = Array("su3cl3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,7 +398,7 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
var empty: InputState?
|
var empty: InputState?
|
||||||
var count = 0
|
var count = 0
|
||||||
|
|
||||||
handler.handle(enter, state: state) { newState in
|
handler.handle(input: enter, state: state) { newState in
|
||||||
switch count {
|
switch count {
|
||||||
case 0:
|
case 0:
|
||||||
committing = newState
|
committing = newState
|
||||||
|
@ -357,7 +408,6 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
count += 1
|
count += 1
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,12 +420,13 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testDelete() {
|
func testDelete() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3cl3").map { String($0) }
|
let keys = Array("su3cl3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,9 +440,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
let delete = KeyHandlerInput(inputText: " ", keyCode: KeyCode.delete.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let delete = KeyHandlerInput(inputText: " ", keyCode: KeyCode.delete.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
var errorCalled = false
|
var errorCalled = false
|
||||||
|
|
||||||
handler.handle(left, state: state) { newState in
|
handler.handle(input: left, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,9 +451,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
XCTAssertEqual(state.cursorIndex, 1)
|
XCTAssertEqual(state.cursorIndex, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.handle(delete, state: state) { newState in
|
handler.handle(input: delete, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,9 +462,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
XCTAssertEqual(state.cursorIndex, 1)
|
XCTAssertEqual(state.cursorIndex, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.handle(delete, state: state) { newState in
|
handler.handle(input: delete, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
errorCalled = true
|
errorCalled = true
|
||||||
}
|
}
|
||||||
|
@ -429,9 +477,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
errorCalled = false
|
errorCalled = false
|
||||||
|
|
||||||
handler.handle(left, state: state) { newState in
|
handler.handle(input: left, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,9 +488,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
XCTAssertEqual(state.cursorIndex, 0)
|
XCTAssertEqual(state.cursorIndex, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.handle(delete, state: state) { newState in
|
handler.handle(input: delete, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,12 +498,13 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testBackspace() {
|
func testBackspace() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3cl3").map { String($0) }
|
let keys = Array("su3cl3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,9 +516,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
let backspace = KeyHandlerInput(inputText: " ", keyCode: 0, charCode: 8, flags: [], isVerticalMode: false)
|
let backspace = KeyHandlerInput(inputText: " ", keyCode: 0, charCode: 8, flags: [], isVerticalMode: false)
|
||||||
|
|
||||||
handler.handle(backspace, state: state) { newState in
|
handler.handle(input: backspace, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,9 +527,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
XCTAssertEqual(state.cursorIndex, 1)
|
XCTAssertEqual(state.cursorIndex, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.handle(backspace, state: state) { newState in
|
handler.handle(input: backspace, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,12 +537,13 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testCursor() {
|
func testCursor() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3cl3").map { String($0) }
|
let keys = Array("su3cl3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,9 +558,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
var errorCalled = false
|
var errorCalled = false
|
||||||
|
|
||||||
handler.handle(left, state: state) { newState in
|
handler.handle(input: left, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||||
|
@ -523,9 +568,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
XCTAssertEqual(state.cursorIndex, 1)
|
XCTAssertEqual(state.cursorIndex, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.handle(left, state: state) { newState in
|
handler.handle(input: left, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||||
|
@ -534,9 +578,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
XCTAssertEqual(state.cursorIndex, 0)
|
XCTAssertEqual(state.cursorIndex, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.handle(left, state: state) { newState in
|
handler.handle(input: left, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
errorCalled = true
|
errorCalled = true
|
||||||
}
|
}
|
||||||
|
@ -547,9 +590,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
}
|
}
|
||||||
XCTAssertTrue(errorCalled)
|
XCTAssertTrue(errorCalled)
|
||||||
|
|
||||||
handler.handle(right, state: state) { newState in
|
handler.handle(input: right, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||||
|
@ -558,9 +600,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
XCTAssertEqual(state.cursorIndex, 1)
|
XCTAssertEqual(state.cursorIndex, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.handle(right, state: state) { newState in
|
handler.handle(input: right, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||||
|
@ -570,9 +611,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
errorCalled = false
|
errorCalled = false
|
||||||
handler.handle(right, state: state) { newState in
|
handler.handle(input: right, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
errorCalled = true
|
errorCalled = true
|
||||||
}
|
}
|
||||||
|
@ -586,12 +626,13 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testCandidateWithDown() {
|
func testCandidateWithDown() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3").map { String($0) }
|
let keys = Array("su3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -602,9 +643,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
let down = KeyHandlerInput(inputText: " ", keyCode: KeyCode.down.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let down = KeyHandlerInput(inputText: " ", keyCode: KeyCode.down.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
handler.handle(down, state: state) { newState in
|
handler.handle(input: down, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,12 +661,13 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
let enabled = Preferences.chooseCandidateUsingSpace
|
let enabled = Preferences.chooseCandidateUsingSpace
|
||||||
Preferences.chooseCandidateUsingSpace = true
|
Preferences.chooseCandidateUsingSpace = true
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3").map { String($0) }
|
let keys = Array("su3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,9 +678,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
let space = KeyHandlerInput(inputText: " ", keyCode: 0, charCode: 32, flags: [], isVerticalMode: false)
|
let space = KeyHandlerInput(inputText: " ", keyCode: 0, charCode: 32, flags: [], isVerticalMode: false)
|
||||||
handler.handle(space, state: state) { newState in
|
handler.handle(input: space, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,14 +693,103 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
Preferences.chooseCandidateUsingSpace = enabled
|
Preferences.chooseCandidateUsingSpace = enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
func testHomeAndEnd() {
|
func testInputSpace() {
|
||||||
|
let enabled = Preferences.chooseCandidateUsingSpace
|
||||||
|
Preferences.chooseCandidateUsingSpace = false
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3cl3").map { String($0) }
|
let keys = Array("su3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
state = newState
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||||
|
if let state = state as? InputState.Inputting {
|
||||||
|
XCTAssertEqual(state.composingBuffer, "你")
|
||||||
|
}
|
||||||
|
|
||||||
|
var count = 0
|
||||||
|
var target: InputState = InputState.Empty()
|
||||||
|
var empty: InputState = InputState.Empty()
|
||||||
|
|
||||||
|
let input = KeyHandlerInput(inputText: " ", keyCode: 0, charCode: 32, flags: [], isVerticalMode: false)
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
switch count {
|
||||||
|
case 0:
|
||||||
|
state = newState
|
||||||
|
case 1:
|
||||||
|
target = newState
|
||||||
|
case 2:
|
||||||
|
empty = newState
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
count += 1
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(count, 3)
|
||||||
|
XCTAssertTrue(state is InputState.Committing, "\(state)")
|
||||||
|
if let state = state as? InputState.Committing {
|
||||||
|
XCTAssertEqual(state.poppedText, "你")
|
||||||
|
}
|
||||||
|
XCTAssertTrue(target is InputState.Committing, "\(target)")
|
||||||
|
if let target = target as? InputState.Committing {
|
||||||
|
XCTAssertEqual(target.poppedText, " ")
|
||||||
|
}
|
||||||
|
XCTAssertTrue(empty is InputState.Empty, "\(empty)")
|
||||||
|
Preferences.chooseCandidateUsingSpace = enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInputSpaceInBetween() {
|
||||||
|
let enabled = Preferences.chooseCandidateUsingSpace
|
||||||
|
Preferences.chooseCandidateUsingSpace = false
|
||||||
|
var state: InputState = InputState.Empty()
|
||||||
|
let keys = Array("su3cl3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
|
for key in keys {
|
||||||
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
state = newState
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||||
|
if let state = state as? InputState.Inputting {
|
||||||
|
XCTAssertEqual(state.composingBuffer, "你好")
|
||||||
|
}
|
||||||
|
|
||||||
|
var input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.left.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
state = newState
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
input = KeyHandlerInput(inputText: " ", keyCode: 0, charCode: 32, flags: [], isVerticalMode: false)
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
state = newState
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
XCTAssertTrue(state is InputState.Inputting, "\(state)")
|
||||||
|
if let state = state as? InputState.Inputting {
|
||||||
|
XCTAssertEqual(state.composingBuffer, "你 好")
|
||||||
|
}
|
||||||
|
Preferences.chooseCandidateUsingSpace = enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHomeAndEnd() {
|
||||||
|
var state: InputState = InputState.Empty()
|
||||||
|
let keys = Array("su3cl3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
|
for key in keys {
|
||||||
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,9 +802,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
let home = KeyHandlerInput(inputText: " ", keyCode: KeyCode.home.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let home = KeyHandlerInput(inputText: " ", keyCode: KeyCode.home.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
let end = KeyHandlerInput(inputText: " ", keyCode: KeyCode.end.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let end = KeyHandlerInput(inputText: " ", keyCode: KeyCode.end.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
|
|
||||||
handler.handle(home, state: state) { newState in
|
handler.handle(input: home, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,9 +813,8 @@ class KeyHandlerBopomofoTests: XCTestCase {
|
||||||
XCTAssertEqual(state.cursorIndex, 0)
|
XCTAssertEqual(state.cursorIndex, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.handle(end, state: state) { newState in
|
handler.handle(input: end, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,8 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
func testPunctuationTable() {
|
func testPunctuationTable() {
|
||||||
let input = KeyHandlerInput(inputText: "`", keyCode: 0, charCode: charCode("`"), flags: .shift, isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "`", keyCode: 0, charCode: charCode("`"), flags: .shift, isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +28,12 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPunctuationComma() {
|
func testPunctuationComma() {
|
||||||
|
let enabled = Preferences.halfWidthPunctuationEnabled
|
||||||
|
Preferences.halfWidthPunctuationEnabled = false
|
||||||
let input = KeyHandlerInput(inputText: "<", keyCode: 0, charCode: charCode("<"), flags: .shift, isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "<", keyCode: 0, charCode: charCode("<"), flags: .shift, isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,14 +41,16 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
if let state = state as? InputState.ChoosingCandidate {
|
if let state = state as? InputState.ChoosingCandidate {
|
||||||
XCTAssertEqual(state.composingBuffer, ",")
|
XCTAssertEqual(state.composingBuffer, ",")
|
||||||
}
|
}
|
||||||
|
Preferences.halfWidthPunctuationEnabled = enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPunctuationPeriod() {
|
func testPunctuationPeriod() {
|
||||||
|
let enabled = Preferences.halfWidthPunctuationEnabled
|
||||||
|
Preferences.halfWidthPunctuationEnabled = false
|
||||||
let input = KeyHandlerInput(inputText: ">", keyCode: 0, charCode: charCode(">"), flags: .shift, isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: ">", keyCode: 0, charCode: charCode(">"), flags: .shift, isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,14 +58,14 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
if let state = state as? InputState.ChoosingCandidate {
|
if let state = state as? InputState.ChoosingCandidate {
|
||||||
XCTAssertEqual(state.composingBuffer, "。")
|
XCTAssertEqual(state.composingBuffer, "。")
|
||||||
}
|
}
|
||||||
|
Preferences.halfWidthPunctuationEnabled = enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInputNe() {
|
func testInputNe() {
|
||||||
let input = KeyHandlerInput(inputText: "s", keyCode: 0, charCode: charCode("s"), flags: .shift, isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: "s", keyCode: 0, charCode: charCode("s"), flags: .shift, isVerticalMode: false)
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,12 +77,13 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testInputNi() {
|
func testInputNi() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su").map { String($0) }
|
let keys = Array("su").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,12 +96,13 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testInputNi3() {
|
func testInputNi3() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3").map { String($0) }
|
let keys = Array("su3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,20 +115,20 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testCancelCandidateUsingDelete() {
|
func testCancelCandidateUsingDelete() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3").map { String($0) }
|
let keys = Array("su3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.delete.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: KeyCode.delete.rawValue, charCode: 0, flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,20 +137,20 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
|
|
||||||
func testCancelCandidateUsingEsc() {
|
func testCancelCandidateUsingEsc() {
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("su3").map { String($0) }
|
let keys = Array("su3").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let input = KeyHandlerInput(inputText: " ", keyCode: 0, charCode: 27, flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: " ", keyCode: 0, charCode: 27, flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,12 +161,13 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
let enabled = Preferences.associatedPhrasesEnabled
|
let enabled = Preferences.associatedPhrasesEnabled
|
||||||
Preferences.associatedPhrasesEnabled = true
|
Preferences.associatedPhrasesEnabled = true
|
||||||
var state: InputState = InputState.Empty()
|
var state: InputState = InputState.Empty()
|
||||||
let keys = Array("aul ").map { String($0) }
|
let keys = Array("aul ").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
for key in keys {
|
for key in keys {
|
||||||
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
handler.handle(input, state: state) { newState in
|
handler.handle(input: input, state: state) { newState in
|
||||||
state = newState
|
state = newState
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,4 +180,24 @@ class KeyHandlerPlainBopomofoTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func testNoAssociatedPhrases() {
|
||||||
|
let enabled = Preferences.associatedPhrasesEnabled
|
||||||
|
Preferences.associatedPhrasesEnabled = false
|
||||||
|
var state: InputState = InputState.Empty()
|
||||||
|
let keys = Array("aul ").map {
|
||||||
|
String($0)
|
||||||
|
}
|
||||||
|
for key in keys {
|
||||||
|
let input = KeyHandlerInput(inputText: key, keyCode: 0, charCode: charCode(key), flags: [], isVerticalMode: false)
|
||||||
|
handler.handle(input: input, state: state) { newState in
|
||||||
|
state = newState
|
||||||
|
|
||||||
|
} errorCallback: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertTrue(state is InputState.Empty, "\(state)")
|
||||||
|
Preferences.associatedPhrasesEnabled = enabled
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class McBopomofoInputMethodController: IMKInputController {
|
||||||
|
|
||||||
let halfWidthPunctuationItem = menu.addItem(withTitle: NSLocalizedString("Use Half-Width Punctuations", comment: ""), action: #selector(toggleHalfWidthPunctuation(_:)), keyEquivalent: "h")
|
let halfWidthPunctuationItem = menu.addItem(withTitle: NSLocalizedString("Use Half-Width Punctuations", comment: ""), action: #selector(toggleHalfWidthPunctuation(_:)), keyEquivalent: "h")
|
||||||
halfWidthPunctuationItem.keyEquivalentModifierMask = [.command, .control]
|
halfWidthPunctuationItem.keyEquivalentModifierMask = [.command, .control]
|
||||||
halfWidthPunctuationItem.state = Preferences.chineseConversionEnabled.state
|
halfWidthPunctuationItem.state = Preferences.halfWidthPunctuationEnabled.state
|
||||||
|
|
||||||
let inputMode = keyHandler.inputMode
|
let inputMode = keyHandler.inputMode
|
||||||
let optionKeyPressed = NSEvent.modifierFlags.contains(.option)
|
let optionKeyPressed = NSEvent.modifierFlags.contains(.option)
|
||||||
|
@ -181,9 +181,8 @@ class McBopomofoInputMethodController: IMKInputController {
|
||||||
|
|
||||||
let input = KeyHandlerInput(event: event, isVerticalMode: useVerticalMode)
|
let input = KeyHandlerInput(event: event, isVerticalMode: useVerticalMode)
|
||||||
|
|
||||||
let result = keyHandler.handle(input, state: state) { newState in
|
let result = keyHandler.handle(input: input, state: state) { newState in
|
||||||
self.handle(state: newState, client: client)
|
self.handle(state: newState, client: client)
|
||||||
} candidateSelectionCallback: {
|
|
||||||
} errorCallback: {
|
} errorCallback: {
|
||||||
NSSound.beep()
|
NSSound.beep()
|
||||||
}
|
}
|
||||||
|
@ -575,7 +574,7 @@ extension McBopomofoInputMethodController: CandidateControllerDelegate {
|
||||||
|
|
||||||
if let state = state as? InputState.ChoosingCandidate {
|
if let state = state as? InputState.ChoosingCandidate {
|
||||||
let selectedValue = state.candidates[Int(index)]
|
let selectedValue = state.candidates[Int(index)]
|
||||||
keyHandler.fixNode(withValue: selectedValue)
|
keyHandler.fixNode(value: selectedValue)
|
||||||
|
|
||||||
guard let inputting = keyHandler.buildInputtingState() as? InputState.Inputting else {
|
guard let inputting = keyHandler.buildInputtingState() as? InputState.Inputting else {
|
||||||
return
|
return
|
||||||
|
|
|
@ -45,11 +45,10 @@ extern InputMode InputModePlainBopomofo;
|
||||||
- (BOOL)handleInput:(KeyHandlerInput *)input
|
- (BOOL)handleInput:(KeyHandlerInput *)input
|
||||||
state:(InputState *)state
|
state:(InputState *)state
|
||||||
stateCallback:(void (^)(InputState *))stateCallback
|
stateCallback:(void (^)(InputState *))stateCallback
|
||||||
candidateSelectionCallback:(void (^)(void))candidateSelectionCallback
|
errorCallback:(void (^)(void))errorCallback NS_SWIFT_NAME(handle(input:state:stateCallback:errorCallback:));
|
||||||
errorCallback:(void (^)(void))errorCallback;
|
|
||||||
|
|
||||||
- (void)syncWithPreferences;
|
- (void)syncWithPreferences;
|
||||||
- (void)fixNodeWithValue:(NSString *)value;
|
- (void)fixNodeWithValue:(NSString *)value NS_SWIFT_NAME(fixNode(value:));
|
||||||
- (void)clear;
|
- (void)clear;
|
||||||
|
|
||||||
- (InputState *)buildInputtingState;
|
- (InputState *)buildInputtingState;
|
||||||
|
|
|
@ -219,7 +219,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)handleInput:(KeyHandlerInput *)input state:(InputState *)inState stateCallback:(void (^)(InputState *))stateCallback candidateSelectionCallback:(void (^)(void))candidateSelectionCallback errorCallback:(void (^)(void))errorCallback
|
- (BOOL)handleInput:(KeyHandlerInput *)input state:(InputState *)inState stateCallback:(void (^)(InputState *))stateCallback errorCallback:(void (^)(void))errorCallback
|
||||||
{
|
{
|
||||||
InputState *state = inState;
|
InputState *state = inState;
|
||||||
UniChar charCode = input.charCode;
|
UniChar charCode = input.charCode;
|
||||||
|
@ -278,12 +278,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
|
|
||||||
// MARK: Handle Candidates
|
// MARK: Handle Candidates
|
||||||
if ([state isKindOfClass:[InputStateChoosingCandidate class]]) {
|
if ([state isKindOfClass:[InputStateChoosingCandidate class]]) {
|
||||||
return [self _handleCandidateState:state input:input stateCallback:stateCallback candidateSelectionCallback:candidateSelectionCallback errorCallback:errorCallback];
|
return [self _handleCandidateState:state input:input stateCallback:stateCallback errorCallback:errorCallback];
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Handle Associated Phrases
|
// MARK: Handle Associated Phrases
|
||||||
if ([state isKindOfClass:[InputStateAssociatedPhrases class]]) {
|
if ([state isKindOfClass:[InputStateAssociatedPhrases class]]) {
|
||||||
BOOL result = [self _handleCandidateState:state input:input stateCallback:stateCallback candidateSelectionCallback:candidateSelectionCallback errorCallback:errorCallback];
|
BOOL result = [self _handleCandidateState:state input:input stateCallback:stateCallback errorCallback:errorCallback];
|
||||||
if (result) {
|
if (result) {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
// MARK: Handle Marking
|
// MARK: Handle Marking
|
||||||
if ([state isKindOfClass:[InputStateMarking class]]) {
|
if ([state isKindOfClass:[InputStateMarking class]]) {
|
||||||
InputStateMarking *marking = (InputStateMarking *) state;
|
InputStateMarking *marking = (InputStateMarking *) state;
|
||||||
if ([self _handleMarkingState:(InputStateMarking *) state input:input stateCallback:stateCallback candidateSelectionCallback:candidateSelectionCallback errorCallback:errorCallback]) {
|
if ([self _handleMarkingState:(InputStateMarking *) state input:input stateCallback:stateCallback errorCallback:errorCallback]) {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
state = [marking convertToInputting];
|
state = [marking convertToInputting];
|
||||||
|
@ -820,7 +820,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
- (BOOL)_handleMarkingState:(InputStateMarking *)state
|
- (BOOL)_handleMarkingState:(InputStateMarking *)state
|
||||||
input:(KeyHandlerInput *)input
|
input:(KeyHandlerInput *)input
|
||||||
stateCallback:(void (^)(InputState *))stateCallback
|
stateCallback:(void (^)(InputState *))stateCallback
|
||||||
candidateSelectionCallback:(void (^)(void))candidateSelectionCallback
|
|
||||||
errorCallback:(void (^)(void))errorCallback
|
errorCallback:(void (^)(void))errorCallback
|
||||||
{
|
{
|
||||||
UniChar charCode = input.charCode;
|
UniChar charCode = input.charCode;
|
||||||
|
@ -880,7 +879,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
- (BOOL)_handleCandidateState:(InputState *)state
|
- (BOOL)_handleCandidateState:(InputState *)state
|
||||||
input:(KeyHandlerInput *)input
|
input:(KeyHandlerInput *)input
|
||||||
stateCallback:(void (^)(InputState *))stateCallback
|
stateCallback:(void (^)(InputState *))stateCallback
|
||||||
candidateSelectionCallback:(void (^)(void))candidateSelectionCallback
|
|
||||||
errorCallback:(void (^)(void))errorCallback;
|
errorCallback:(void (^)(void))errorCallback;
|
||||||
{
|
{
|
||||||
NSString *inputText = input.inputText;
|
NSString *inputText = input.inputText;
|
||||||
|
@ -922,7 +920,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
if (!updated) {
|
if (!updated) {
|
||||||
errorCallback();
|
errorCallback();
|
||||||
}
|
}
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,7 +928,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
if (!updated) {
|
if (!updated) {
|
||||||
errorCallback();
|
errorCallback();
|
||||||
}
|
}
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,7 +943,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
errorCallback();
|
errorCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,7 +951,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
if (!updated) {
|
if (!updated) {
|
||||||
errorCallback();
|
errorCallback();
|
||||||
}
|
}
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,7 +966,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
errorCallback();
|
errorCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -981,7 +974,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
if (!updated) {
|
if (!updated) {
|
||||||
errorCallback();
|
errorCallback();
|
||||||
}
|
}
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,7 +989,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
errorCallback();
|
errorCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,7 +1004,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
errorCallback();
|
errorCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1024,7 +1014,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
gCurrentCandidateController.selectedCandidateIndex = 0;
|
gCurrentCandidateController.selectedCandidateIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,8 +1035,6 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
} else {
|
} else {
|
||||||
gCurrentCandidateController.selectedCandidateIndex = candidates.count - 1;
|
gCurrentCandidateController.selectedCandidateIndex = candidates.count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,14 +1102,13 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
[self clear];
|
[self clear];
|
||||||
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
|
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
|
||||||
stateCallback(empty);
|
stateCallback(empty);
|
||||||
[self handleInput:input state:empty stateCallback:stateCallback candidateSelectionCallback:candidateSelectionCallback errorCallback:errorCallback];
|
[self handleInput:input state:empty stateCallback:stateCallback errorCallback:errorCallback];
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errorCallback();
|
errorCallback();
|
||||||
candidateSelectionCallback();
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue