From 83801eee1ba47dcf59f5781b9285003399c6c0fe Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 13 Dec 2022 22:38:57 +0800 Subject: [PATCH] InputHandler // Accommodating changes introduced in Megrez 2.5.0 update. --- Source/Modules/InputHandler_Core.swift | 12 ++++++------ Source/Modules/InputHandler_HandleStates.swift | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Modules/InputHandler_Core.swift b/Source/Modules/InputHandler_Core.swift index bc572d40..5586f26b 100644 --- a/Source/Modules/InputHandler_Core.swift +++ b/Source/Modules/InputHandler_Core.swift @@ -113,7 +113,7 @@ public class InputHandler: InputHandlerProtocol { func isCursorCuttingChar(isMarker: Bool = false) -> Bool { let index = isMarker ? compositor.marker : compositor.cursor var isBound = (index == compositor.walkedNodes.contextRange(ofGivenCursor: index).lowerBound) - if index == compositor.width { isBound = true } + if index == compositor.length { isBound = true } let rawResult = compositor.walkedNodes.findNode(at: index)?.isReadingMismatched ?? false return !isBound && rawResult } @@ -123,7 +123,7 @@ public class InputHandler: InputHandlerProtocol { /// 威注音對游標前置與游標後置模式採取的候選字節點陣列抓取方法是分離的,且不使用 Node Crossing。 var cursorForCandidate: Int { compositor.cursor - - ((compositor.cursor == compositor.width || !prefs.useRearCursorMode) && compositor.cursor > 0 ? 1 : 0) + - ((compositor.cursor == compositor.length || !prefs.useRearCursorMode) && compositor.cursor > 0 ? 1 : 0) } /// 利用給定的讀音鏈來試圖爬取最接近的組字結果(最大相似度估算)。 @@ -197,7 +197,7 @@ public class InputHandler: InputHandlerProtocol { rearBoundary = min(compositor.cursor, rearBoundary) compositor.cursor = cursorBackup // 游標歸位,再接著計算。 while compositor.cursor < frontBoundary { compositor.jumpCursorBySpan(to: .front) } - frontBoundary = min(max(compositor.cursor, frontBoundary), compositor.width) + frontBoundary = min(max(compositor.cursor, frontBoundary), compositor.length) compositor.cursor = cursorBackup // 計算結束,游標歸位。 debugIntelToPrint.append("FIN: \(rearBoundary)..<\(frontBoundary)") @@ -479,14 +479,14 @@ extension InputHandler { /// 用比較形象且生動卻有點噁心的解釋的話,蒼蠅一邊吃一邊屙。 var commitOverflownComposition: String { guard !compositor.walkedNodes.isEmpty, - compositor.width > compositorWidthLimit, + compositor.length > compositorWidthLimit, let identifier = delegate?.clientBundleIdentifier, prefs.clientsIMKTextInputIncapable.contains(identifier) else { return "" } // 回頭在這裡插上對 Steam 的 Client Identifier 的要求。 var textToCommit = "" - while compositor.width > compositorWidthLimit { - var delta = compositor.width - compositorWidthLimit + while compositor.length > compositorWidthLimit { + var delta = compositor.length - compositorWidthLimit let node = compositor.walkedNodes[0] if node.isReadingMismatched { delta = node.keyArray.count diff --git a/Source/Modules/InputHandler_HandleStates.swift b/Source/Modules/InputHandler_HandleStates.swift index b5f8a00b..d1475426 100644 --- a/Source/Modules/InputHandler_HandleStates.swift +++ b/Source/Modules/InputHandler_HandleStates.swift @@ -209,7 +209,7 @@ extension InputHandler { // Shift + Right if input.isCursorForward, input.isShiftHold { - if compositor.marker < compositor.width { + if compositor.marker < compositor.length { compositor.marker += 1 if isCursorCuttingChar(isMarker: true) { compositor.jumpCursorBySpan(to: .front, isMarker: true) @@ -562,7 +562,7 @@ extension InputHandler { if input.isShiftHold { // Shift + Right - if compositor.cursor < compositor.width { + if compositor.cursor < compositor.length { compositor.marker = compositor.cursor + 1 if isCursorCuttingChar(isMarker: true) { compositor.jumpCursorBySpan(to: .front, isMarker: true) @@ -709,7 +709,7 @@ extension InputHandler { let currentPaired = (currentNode.keyArray, currentNode.value) var currentIndex = 0 - if !currentNode.isOverriden { + if !currentNode.isOverridden { /// 如果是沒有被使用者手動選字過的(節錨下的)節點, /// 就從第一個候選字詞開始,這樣使用者在敲字時就會優先匹配 /// 那些字詞長度不小於 2 的單元圖。換言之,如果使用者敲了兩個