InputHandler // Accommodating changes introduced in Megrez 2.5.0 update.

This commit is contained in:
ShikiSuen 2022-12-13 22:38:57 +08:00
parent 258d2f7362
commit 83801eee1b
2 changed files with 9 additions and 9 deletions

View File

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

View File

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