Skip to content

Commit 41895cb

Browse files
committed
KBEvent & Typewriter // Fix typos among API names.
1 parent 232f069 commit 41895cb

12 files changed

Lines changed: 66 additions & 66 deletions

File tree

Packages/vChewing_MainAssembly4Darwin/Sources/MainAssembly4Darwin/SessionController/InputSession_HandleEvent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ extension SessionProtocol {
168168
let eventCharConverted = eventToDeal.characters?.applyingTransformFW2HW(reverse: false) {
169169
eventToDeal = eventToDeal.reinitiate(characters: eventCharConverted)
170170
} else if [.ofEmpty, .ofInputting].contains(state.type), eventToDeal.isMainAreaNumKey,
171-
!eventToDeal.isCommandHold, !eventToDeal.isControlHold, eventToDeal.isOptionHold {
171+
!eventToDeal.isCommandHeld, !eventToDeal.isControlHeld, eventToDeal.isOptionHeld {
172172
// Alt(+Shift)+主鍵盤區數字鍵 預先處理
173173
eventToDeal = eventToDeal.reinitiate(characters: eventToDeal.mainAreaNumKeyChar)
174174
}

Packages/vChewing_Shared/Sources/Shared/KBEvent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ extension KBEvent {
168168
public var isFlagChanged: Bool { type == .flagsChanged }
169169

170170
public var isEmacsKey: Bool {
171-
// 這裡不能只用 isControlHold,因為這裡對修飾鍵的要求有排他性。
171+
// 這裡不能只用 isControlHeld,因為這裡對修飾鍵的要求有排他性。
172172
[6, 2, 1, 5, 4, 22, 14, 16].contains(charCode) && keyModifierFlags == .control
173173
}
174174

@@ -512,7 +512,7 @@ extension KBEvent {
512512
if !mapTable.keys.contains(keyCode) { return self }
513513
guard let dataTuplet = mapTable[keyCode] else { return self }
514514
let result: KBEvent = reinitiate(
515-
characters: isShiftHold ? dataTuplet.1 : dataTuplet.0,
515+
characters: isShiftHeld ? dataTuplet.1 : dataTuplet.0,
516516
charactersIgnoringModifiers: dataTuplet.0
517517
)
518518
return result

Packages/vChewing_Shared/Sources/Shared/Protocols/InputSignalProtocol.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public protocol InputSignalProtocol {
2626
var isJISKanaSwappingKey: Bool { get }
2727
var isNumericPadKey: Bool { get }
2828
var isMainAreaNumKey: Bool { get }
29-
var isShiftHold: Bool { get }
30-
var isCommandHold: Bool { get }
31-
var isControlHold: Bool { get }
29+
var isShiftHeld: Bool { get }
30+
var isCommandHeld: Bool { get }
31+
var isControlHeld: Bool { get }
3232
var beganWithLetter: Bool { get }
33-
var isOptionHold: Bool { get }
33+
var isOptionHeld: Bool { get }
3434
var isCapsLockOn: Bool { get }
35-
var isFunctionKeyHold: Bool { get }
35+
var isFunctionKeyHeld: Bool { get }
3636
var isNonLaptopFunctionKey: Bool { get }
3737
var isEnter: Bool { get }
3838
var isTab: Bool { get }
@@ -89,11 +89,11 @@ extension InputSignalProtocol {
8989

9090
// MARK: Modifier key queries
9191

92-
public var isShiftHold: Bool { keyModifierFlags.contains(.shift) }
93-
public var isCommandHold: Bool { keyModifierFlags.contains(.command) }
94-
public var isControlHold: Bool { keyModifierFlags.contains(.control) }
95-
public var isOptionHold: Bool { keyModifierFlags.contains(.option) }
96-
public var isFunctionKeyHold: Bool { keyModifierFlags.contains(.function) }
92+
public var isShiftHeld: Bool { keyModifierFlags.contains(.shift) }
93+
public var isCommandHeld: Bool { keyModifierFlags.contains(.command) }
94+
public var isControlHeld: Bool { keyModifierFlags.contains(.control) }
95+
public var isOptionHeld: Bool { keyModifierFlags.contains(.option) }
96+
public var isFunctionKeyHeld: Bool { keyModifierFlags.contains(.function) }
9797
public var beganWithLetter: Bool { text.first?.isLetter ?? false }
9898

9999
public var isNonLaptopFunctionKey: Bool {

Packages/vChewing_Shared_DarwinImpl/Sources/Shared_DarwinImpl/NSEventImpl.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extension NSEvent {
102102
public var isFlagChanged: Bool { type == .flagsChanged }
103103

104104
public var isEmacsKey: Bool {
105-
// 這裡不能只用 isControlHold,因為這裡對修飾鍵的要求有排他性。
105+
// 這裡不能只用 isControlHeld,因為這裡對修飾鍵的要求有排他性。
106106
[6, 2, 1, 5, 4, 22, 14, 16].contains(charCode) && keyModifierFlagsNS == .control
107107
}
108108

@@ -128,7 +128,7 @@ extension NSEvent {
128128
if !mapTable.keys.contains(keyCode) { return self }
129129
guard let dataTuplet = mapTable[keyCode] else { return self }
130130
let result: NSEvent? = reinitiate(
131-
characters: isShiftHold ? dataTuplet.1 : dataTuplet.0,
131+
characters: isShiftHeld ? dataTuplet.1 : dataTuplet.0,
132132
charactersIgnoringModifiers: dataTuplet.0
133133
)
134134
return result ?? self

Packages/vChewing_Typewriter/Sources/Typewriter/InputHandler/InputHandler_CoreProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ extension InputHandlerProtocol {
865865
input.commonKeyModifierFlags == [.option, .shift] {
866866
return "_shift_alt_punctuation_"
867867
}
868-
switch (input.isControlHold, input.isOptionHold) {
868+
switch (input.isControlHeld, input.isOptionHeld) {
869869
case (true, true): return "_alt_ctrl_punctuation_"
870870
case (true, false): return "_ctrl_punctuation_"
871871
case (false, true): return "_alt_punctuation_"

Packages/vChewing_Typewriter/Sources/Typewriter/InputHandler/InputHandler_HandleCandidate.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ extension InputHandlerProtocol {
143143
switch keyCodeType {
144144
case .kCarriageReturn, .kLineFeed:
145145
if state.type == .ofAssociates,
146-
!(input.isShiftHold || prefs.alsoConfirmAssociatedCandidatesByEnter) {
146+
!(input.isShiftHeld || prefs.alsoConfirmAssociatedCandidatesByEnter) {
147147
session.switchState(State.ofAbortion())
148148
return true
149149
}
@@ -171,12 +171,12 @@ extension InputHandlerProtocol {
171171
let updated: Bool =
172172
prefs.specifyShiftTabKeyBehavior
173173
? (
174-
input.isShiftHold
174+
input.isShiftHeld
175175
? ctlCandidate.showPreviousLine()
176176
: ctlCandidate.showNextLine()
177177
)
178178
: (
179-
input.isShiftHold
179+
input.isShiftHeld
180180
? ctlCandidate.highlightPreviousCandidate()
181181
: ctlCandidate.highlightNextCandidate()
182182
)
@@ -193,12 +193,12 @@ extension InputHandlerProtocol {
193193
let updated: Bool =
194194
effectiveSpecifyShift
195195
? (
196-
input.isShiftHold
196+
input.isShiftHeld
197197
? ctlCandidate.highlightNextCandidate()
198198
: ctlCandidate.showNextLine()
199199
)
200200
: (
201-
input.isShiftHold
201+
input.isShiftHeld
202202
? ctlCandidate.showNextLine()
203203
: ctlCandidate.highlightNextCandidate()
204204
)
@@ -286,7 +286,7 @@ extension InputHandlerProtocol {
286286

287287
// MARK: 關聯詞語處理 (Associated Phrases) 以及標準選字處理
288288

289-
if state.type == .ofAssociates, !input.isShiftHold { return false }
289+
if state.type == .ofAssociates, !input.isShiftHeld { return false }
290290

291291
var index: Int?
292292
var shaltShiftHold = [.ofAssociates].contains(state.type)

Packages/vChewing_Typewriter/Sources/Typewriter/InputHandler/InputHandler_HandleStates.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ extension InputHandlerProtocol {
354354
}
355355

356356
// Shift + Left
357-
if input.isCursorBackward, input.isShiftHold {
357+
if input.isCursorBackward, input.isShiftHeld {
358358
let moved: Bool = {
359359
if input.isHoldingAny([.command, .option]) {
360360
return (try? assembler.jumpCursorBySegment(to: .rear, isMarker: true)) != nil
@@ -384,7 +384,7 @@ extension InputHandlerProtocol {
384384
}
385385

386386
// Shift + Right
387-
if input.isCursorForward, input.isShiftHold {
387+
if input.isCursorForward, input.isShiftHeld {
388388
let moved: Bool = {
389389
if input.isHoldingAny([.command, .option]) {
390390
return (try? assembler.jumpCursorBySegment(to: .front, isMarker: true)) != nil
@@ -517,9 +517,9 @@ extension InputHandlerProtocol {
517517
} else if readingOnly {
518518
displayedText = commissionByCtrlCommandEnter()
519519
} else if input.isHoldingAll([.command, .control]) {
520-
displayedText = input.isOptionHold
521-
? commissionByCtrlOptionCommandEnter(isShiftPressed: input.isShiftHold)
522-
: commissionByCtrlCommandEnter(isShiftPressed: input.isShiftHold)
520+
displayedText = input.isOptionHeld
521+
? commissionByCtrlOptionCommandEnter(isShiftPressed: input.isShiftHeld)
522+
: commissionByCtrlCommandEnter(isShiftPressed: input.isShiftHeld)
523523
}
524524

525525
session.switchState(State.ofCommitting(textToCommit: displayedText))
@@ -604,14 +604,14 @@ extension InputHandlerProtocol {
604604
switch prefs.specifyShiftBackSpaceKeyBehavior {
605605
case 0:
606606
if prefs.cassetteEnabled {
607-
guard input.isShiftHold, calligrapher.isEmpty else { break shiftBksp }
607+
guard input.isShiftHeld, calligrapher.isEmpty else { break shiftBksp }
608608
guard let prevReading = previousParsableCalligraph else { break shiftBksp }
609609
// 此處刻意使用 Assembler 的 API(assembler.dropKey)以避免呼叫
610610
// InputHandler 的 dropKey 中所包含的 KeyDropContext 回補邏輯。
611611
try? assembler.dropKey(direction: .rear)
612612
calligrapher = prevReading
613613
} else {
614-
guard input.isShiftHold, isComposerOrCalligrapherEmpty else { break shiftBksp }
614+
guard input.isShiftHeld, isComposerOrCalligrapherEmpty else { break shiftBksp }
615615
guard let prevReading = previousParsableReading else { break shiftBksp }
616616
// prevReading 的內容分別是:「完整讀音」「去掉聲調的讀音」「是否有聲調」。
617617
// 此處刻意使用 Assembler 的 API(assembler.dropKey)以避免呼叫
@@ -860,7 +860,7 @@ extension InputHandlerProtocol {
860860
return true
861861
}
862862

863-
if input.isShiftHold {
863+
if input.isShiftHeld {
864864
// Shift + Right
865865
if assembler.cursor < assembler.length {
866866
assembler.marker = assembler.cursor
@@ -889,8 +889,8 @@ extension InputHandlerProtocol {
889889
} else {
890890
errorCallback?("BB7F6DB9")
891891
}
892-
} else if input.isOptionHold, !input.isShiftHold {
893-
if input.isControlHold {
892+
} else if input.isOptionHeld, !input.isShiftHeld {
893+
if input.isControlHeld {
894894
return handleEnd()
895895
}
896896
// 游標跳轉動作無論怎樣都會執行,但如果出了執行失敗的結果的話則觸發報錯流程。
@@ -926,7 +926,7 @@ extension InputHandlerProtocol {
926926
return true
927927
}
928928

929-
if input.isShiftHold {
929+
if input.isShiftHeld {
930930
// Shift + left
931931
if assembler.cursor > 0 {
932932
assembler.marker = assembler.cursor
@@ -958,8 +958,8 @@ extension InputHandlerProtocol {
958958
} else {
959959
errorCallback?("D326DEA3")
960960
}
961-
} else if input.isOptionHold, !input.isShiftHold {
962-
if input.isControlHold { return handleHome() }
961+
} else if input.isOptionHeld, !input.isShiftHeld {
962+
if input.isControlHeld { return handleHome() }
963963
// 游標跳轉動作無論怎樣都會執行,但如果出了執行失敗的結果的話則觸發報錯流程。
964964
if (try? assembler.jumpCursorBySegment(to: .rear)) == nil {
965965
errorCallback?("8D50DD9E")
@@ -1150,7 +1150,7 @@ extension InputHandlerProtocol {
11501150

11511151
// 字母鍵摁 Shift 的話,無須額外處理,因為直接就會敲出大寫字母。
11521152
var shiftCapsLockHandling = input.isUpperCaseASCIILetterKey && session.isASCIIMode
1153-
shiftCapsLockHandling = shiftCapsLockHandling || handleCapsLock && input.isShiftHold
1153+
shiftCapsLockHandling = shiftCapsLockHandling || handleCapsLock && input.isShiftHeld
11541154
guard !shiftCapsLockHandling else { return false }
11551155

11561156
// 不再讓唯音處理由 Shift 切換到的英文模式的按鍵輸入。
@@ -1177,7 +1177,7 @@ extension InputHandlerProtocol {
11771177
var state: State { session.state }
11781178
// 用上下左右鍵呼叫選字窗。
11791179
// 僅憑藉 state.hasComposition 的話,並不能真實把握組字器的狀況。
1180-
// 另外,這裡不要用「!input.isFunctionKeyHold」,
1180+
// 另外,這裡不要用「!input.isFunctionKeyHeld」,
11811181
// 否則會導致對上下左右鍵與翻頁鍵的判斷失效。
11821182
let notEmpty = state.hasComposition && !assembler.isEmpty && isComposerOrCalligrapherEmpty
11831183
let bannedModifiers: KBEvent.ModifierFlags = [.option, .shift, .command, .control]
@@ -1202,10 +1202,10 @@ extension InputHandlerProtocol {
12021202
func handleArabicNumeralInputs(input: InputSignalProtocol) -> Bool {
12031203
guard let session = session else { return false }
12041204
guard session.state.type == .ofEmpty, input.isMainAreaNumKey else { return false }
1205-
guard input.isOptionHold, !input.isHoldingAny([.command, .control]) else { return false }
1205+
guard input.isOptionHeld, !input.isHoldingAny([.command, .control]) else { return false }
12061206
guard let strRAW = input.mainAreaNumKeyChar else { return false }
12071207
let newString: String = {
1208-
if input.isShiftHold {
1208+
if input.isShiftHeld {
12091209
return strRAW.applyingTransformFW2HW(reverse: !prefs.halfWidthPunctuationEnabled)
12101210
}
12111211
return strRAW.applyingTransformFW2HW(reverse: false)
@@ -1223,7 +1223,7 @@ extension InputHandlerProtocol {
12231223
guard let session = session else { return false }
12241224
let inputText = input.text
12251225
if input.isUpperCaseASCIILetterKey, !input.isHoldingAny([.command, .control]) {
1226-
if input.isShiftHold { // 這裡先不要判斷 isOptionHold
1226+
if input.isShiftHeld { // 這裡先不要判斷 isOptionHeld
12271227
switch prefs.upperCaseLetterKeyBehavior {
12281228
case 1, 3:
12291229
if prefs.upperCaseLetterKeyBehavior == 3, !isConsideredEmptyForNow { break }

Packages/vChewing_Typewriter/Sources/Typewriter/InputHandler/InputHandler_TriageInput.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extension InputHandlerProtocol {
2424
switch keyCodeType {
2525
case .kEscape: return handleEsc()
2626
case .kContextMenu, .kTab: return revolveCandidate(
27-
reverseOrder: input.isShiftHold,
27+
reverseOrder: input.isShiftHeld,
2828
softRevolve: prefs.preferredRevolverForceLevel == 2
2929
)
3030
case .kDownArrow, .kLeftArrow, .kRightArrow, .kUpArrow:
@@ -78,7 +78,7 @@ extension InputHandlerProtocol {
7878
switch state.type {
7979
case .ofEmpty:
8080
if !input.isHoldingAny([.option, .control, .command]) {
81-
session.switchState(State.ofCommitting(textToCommit: input.isShiftHold ? " " : " "))
81+
session.switchState(State.ofCommitting(textToCommit: input.isShiftHeld ? " " : " "))
8282
return true
8383
}
8484
case .ofInputting:
@@ -89,13 +89,13 @@ extension InputHandlerProtocol {
8989
// 此時 Shift+Space 反向輪替,仿 Shift+Tab 行為。
9090
// SPACE 啟動的輪替一律套用 soft revolve,避免毀掉鄰近已覆寫節點。
9191
return revolveCandidate(
92-
reverseOrder: input.isShiftHold,
92+
reverseOrder: input.isShiftHeld,
9393
softRevolve: prefs.preferredRevolverForceLevel != 0
9494
)
9595
}
96-
if input.isShiftHold, !input.isHoldingAny([.control, .option]) {
96+
if input.isShiftHeld, !input.isHoldingAny([.control, .option]) {
9797
return revolveCandidate(
98-
reverseOrder: input.isCommandHold,
98+
reverseOrder: input.isCommandHeld,
9999
softRevolve: prefs.preferredRevolverForceLevel != 0
100100
)
101101
}
@@ -161,7 +161,7 @@ extension InputHandlerProtocol {
161161
// 如果當前組字器為空的話,就不再攔截 Cmd / 非筆電功能鍵,
162162
// 畢竟這些鍵可能會用來觸發系統功能。
163163
if !state.hasComposition,
164-
input.isCommandHold || input.isNonLaptopFunctionKey { return false }
164+
input.isCommandHeld || input.isNonLaptopFunctionKey { return false }
165165

166166
// 若 Caps Lock 被啟用的話,則暫停對注音輸入的處理。
167167
// 這裡的處理仍舊有用,不然 Caps Lock 英文模式無法直接鍵入小寫字母。

Packages/vChewing_Typewriter/Sources/Typewriter/Typewriter/Typewriter_BPMFFullMatch.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public struct BPMFFullMatchTypewriter<Handler: InputHandlerProtocol>: Typewriter
4141
let existedIntonation = handler.composer.intonation
4242
let skipPhoneticHandling =
4343
input.isReservedKey || input.isNumericPadKey || input.isNonLaptopFunctionKey
44-
|| input.isControlHold || input.isOptionHold || input.isShiftHold || input.isCommandHold
44+
|| input.isControlHeld || input.isOptionHeld || input.isShiftHeld || input.isCommandHeld
4545
let confirmCombination = input.isSpace || input.isEnter
4646

4747
// 先嘗試讓注拼槽消化當前按鍵(含可能的聲調覆寫),以保留既有行為。
@@ -253,8 +253,8 @@ public struct BPMFFullMatchTypewriter<Handler: InputHandlerProtocol>: Typewriter
253253
composeReading = composeReading || (!handler.composer.isEmpty && confirmCombination)
254254
guard composeReading else { return nil }
255255

256-
if input.isControlHold, input.isCommandHold, input.isEnter,
257-
!input.isOptionHold, !input.isShiftHold, handler.assembler.isEmpty {
256+
if input.isControlHeld, input.isCommandHeld, input.isEnter,
257+
!input.isOptionHeld, !input.isShiftHeld, handler.assembler.isEmpty {
258258
return handler.handleEnter(input: input, readingOnly: true)
259259
}
260260

Packages/vChewing_Typewriter/Sources/Typewriter/Typewriter/Typewriter_Cassette.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public struct CassetteTypewriter<Handler: InputHandlerProtocol>: TypewriterProto
5151

5252
let skipStrokeHandling =
5353
input.isReservedKey || input.isNumericPadKey || input.isNonLaptopFunctionKey
54-
|| input.isControlHold || input.isOptionHold || input.isCommandHold
54+
|| input.isControlHeld || input.isOptionHeld || input.isCommandHeld
5555
let isCalligrapherFull = handler.calligrapher.count >= currentLM.maxCassetteKeyLength
5656
var didAppendStroke = false
5757

@@ -119,7 +119,7 @@ public struct CassetteTypewriter<Handler: InputHandlerProtocol>: TypewriterProto
119119
let currentLM = handler.currentLM
120120
let hasQuickCandidates = state.type == .ofInputting && state.isCandidateContainer
121121
var handleQuickCandidate = true
122-
if currentLM.areCassetteCandidateKeysShiftHeld { handleQuickCandidate = input.isShiftHold }
122+
if currentLM.areCassetteCandidateKeysShiftHeld { handleQuickCandidate = input.isShiftHeld }
123123

124124
if handler.handleCassetteSymbolTable(input: input) { return true }
125125

@@ -249,8 +249,8 @@ public struct CassetteTypewriter<Handler: InputHandlerProtocol>: TypewriterProto
249249
// 執行真正的組字:插入讀音、呼叫組句、處理溢出、刷新狀態並考慮逐字選字模式。
250250
let currentLM = handler.currentLM
251251
guard !handler.calligrapher.isEmpty else { return nil }
252-
if input.isControlHold, input.isCommandHold, input.isEnter,
253-
!input.isOptionHold, !input.isShiftHold, handler.composer.isEmpty {
252+
if input.isControlHeld, input.isCommandHeld, input.isEnter,
253+
!input.isOptionHeld, !input.isShiftHeld, handler.composer.isEmpty {
254254
return handler.handleEnter(input: input, readingOnly: true)
255255
}
256256
if !currentLM.hasUnigramsFor(keyArray: [handler.calligrapher]) {

0 commit comments

Comments
 (0)