InputHandler // Accommodating changes introduced in Megrez 2.5.0 update.
This commit is contained in:
parent
258d2f7362
commit
83801eee1b
|
@ -113,7 +113,7 @@ public class InputHandler: InputHandlerProtocol {
|
||||||
func isCursorCuttingChar(isMarker: Bool = false) -> Bool {
|
func isCursorCuttingChar(isMarker: Bool = false) -> Bool {
|
||||||
let index = isMarker ? compositor.marker : compositor.cursor
|
let index = isMarker ? compositor.marker : compositor.cursor
|
||||||
var isBound = (index == compositor.walkedNodes.contextRange(ofGivenCursor: index).lowerBound)
|
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
|
let rawResult = compositor.walkedNodes.findNode(at: index)?.isReadingMismatched ?? false
|
||||||
return !isBound && rawResult
|
return !isBound && rawResult
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class InputHandler: InputHandlerProtocol {
|
||||||
/// 威注音對游標前置與游標後置模式採取的候選字節點陣列抓取方法是分離的,且不使用 Node Crossing。
|
/// 威注音對游標前置與游標後置模式採取的候選字節點陣列抓取方法是分離的,且不使用 Node Crossing。
|
||||||
var cursorForCandidate: Int {
|
var cursorForCandidate: Int {
|
||||||
compositor.cursor
|
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)
|
rearBoundary = min(compositor.cursor, rearBoundary)
|
||||||
compositor.cursor = cursorBackup // 游標歸位,再接著計算。
|
compositor.cursor = cursorBackup // 游標歸位,再接著計算。
|
||||||
while compositor.cursor < frontBoundary { compositor.jumpCursorBySpan(to: .front) }
|
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 // 計算結束,游標歸位。
|
compositor.cursor = cursorBackup // 計算結束,游標歸位。
|
||||||
|
|
||||||
debugIntelToPrint.append("FIN: \(rearBoundary)..<\(frontBoundary)")
|
debugIntelToPrint.append("FIN: \(rearBoundary)..<\(frontBoundary)")
|
||||||
|
@ -479,14 +479,14 @@ extension InputHandler {
|
||||||
/// 用比較形象且生動卻有點噁心的解釋的話,蒼蠅一邊吃一邊屙。
|
/// 用比較形象且生動卻有點噁心的解釋的話,蒼蠅一邊吃一邊屙。
|
||||||
var commitOverflownComposition: String {
|
var commitOverflownComposition: String {
|
||||||
guard !compositor.walkedNodes.isEmpty,
|
guard !compositor.walkedNodes.isEmpty,
|
||||||
compositor.width > compositorWidthLimit,
|
compositor.length > compositorWidthLimit,
|
||||||
let identifier = delegate?.clientBundleIdentifier,
|
let identifier = delegate?.clientBundleIdentifier,
|
||||||
prefs.clientsIMKTextInputIncapable.contains(identifier)
|
prefs.clientsIMKTextInputIncapable.contains(identifier)
|
||||||
else { return "" }
|
else { return "" }
|
||||||
// 回頭在這裡插上對 Steam 的 Client Identifier 的要求。
|
// 回頭在這裡插上對 Steam 的 Client Identifier 的要求。
|
||||||
var textToCommit = ""
|
var textToCommit = ""
|
||||||
while compositor.width > compositorWidthLimit {
|
while compositor.length > compositorWidthLimit {
|
||||||
var delta = compositor.width - compositorWidthLimit
|
var delta = compositor.length - compositorWidthLimit
|
||||||
let node = compositor.walkedNodes[0]
|
let node = compositor.walkedNodes[0]
|
||||||
if node.isReadingMismatched {
|
if node.isReadingMismatched {
|
||||||
delta = node.keyArray.count
|
delta = node.keyArray.count
|
||||||
|
|
|
@ -209,7 +209,7 @@ extension InputHandler {
|
||||||
|
|
||||||
// Shift + Right
|
// Shift + Right
|
||||||
if input.isCursorForward, input.isShiftHold {
|
if input.isCursorForward, input.isShiftHold {
|
||||||
if compositor.marker < compositor.width {
|
if compositor.marker < compositor.length {
|
||||||
compositor.marker += 1
|
compositor.marker += 1
|
||||||
if isCursorCuttingChar(isMarker: true) {
|
if isCursorCuttingChar(isMarker: true) {
|
||||||
compositor.jumpCursorBySpan(to: .front, isMarker: true)
|
compositor.jumpCursorBySpan(to: .front, isMarker: true)
|
||||||
|
@ -562,7 +562,7 @@ extension InputHandler {
|
||||||
|
|
||||||
if input.isShiftHold {
|
if input.isShiftHold {
|
||||||
// Shift + Right
|
// Shift + Right
|
||||||
if compositor.cursor < compositor.width {
|
if compositor.cursor < compositor.length {
|
||||||
compositor.marker = compositor.cursor + 1
|
compositor.marker = compositor.cursor + 1
|
||||||
if isCursorCuttingChar(isMarker: true) {
|
if isCursorCuttingChar(isMarker: true) {
|
||||||
compositor.jumpCursorBySpan(to: .front, isMarker: true)
|
compositor.jumpCursorBySpan(to: .front, isMarker: true)
|
||||||
|
@ -709,7 +709,7 @@ extension InputHandler {
|
||||||
let currentPaired = (currentNode.keyArray, currentNode.value)
|
let currentPaired = (currentNode.keyArray, currentNode.value)
|
||||||
|
|
||||||
var currentIndex = 0
|
var currentIndex = 0
|
||||||
if !currentNode.isOverriden {
|
if !currentNode.isOverridden {
|
||||||
/// 如果是沒有被使用者手動選字過的(節錨下的)節點,
|
/// 如果是沒有被使用者手動選字過的(節錨下的)節點,
|
||||||
/// 就從第一個候選字詞開始,這樣使用者在敲字時就會優先匹配
|
/// 就從第一個候選字詞開始,這樣使用者在敲字時就會優先匹配
|
||||||
/// 那些字詞長度不小於 2 的單元圖。換言之,如果使用者敲了兩個
|
/// 那些字詞長度不小於 2 的單元圖。換言之,如果使用者敲了兩個
|
||||||
|
|
Loading…
Reference in New Issue