From 5f654c842ec91a55ef5533aa737108dc23b79179 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 12 Jul 2022 15:55:18 +0800 Subject: [PATCH] KeyHandler // Improve Alt+Fwd/Bwd support. --- .../ControllerModules/KeyHandler_Core.swift | 4 ++-- .../ControllerModules/KeyHandler_States.swift | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler_Core.swift b/Source/Modules/ControllerModules/KeyHandler_Core.swift index 63f24dfa..998f381e 100644 --- a/Source/Modules/ControllerModules/KeyHandler_Core.swift +++ b/Source/Modules/ControllerModules/KeyHandler_Core.swift @@ -375,8 +375,8 @@ class KeyHandler { /// 組字器的游標位置。 var compositorCursorIndex: Int { - get { compositor.cursorIndex } - set { compositor.cursorIndex = newValue } + get { compositor.cursor } + set { compositor.cursor = newValue } } /// 組字器的目前的長度。 diff --git a/Source/Modules/ControllerModules/KeyHandler_States.swift b/Source/Modules/ControllerModules/KeyHandler_States.swift index ae662528..401bcaf1 100644 --- a/Source/Modules/ControllerModules/KeyHandler_States.swift +++ b/Source/Modules/ControllerModules/KeyHandler_States.swift @@ -662,14 +662,14 @@ extension KeyHandler { stateCallback(state) } } else if input.isOptionHold { - if compositorCursorIndex < compositorLength { - compositorCursorIndex = nextPhrasePosition - stateCallback(buildInputtingState) - } else { + // 游標跳轉動作無論怎樣都會執行,但如果出了執行失敗的結果的話則觸發報錯流程。 + if !compositor.jumpCursorBySpan(to: .front) { IME.prtDebugIntel("33C3B580") errorCallback() stateCallback(state) + return true } + stateCallback(buildInputtingState) } else { if compositorCursorIndex < compositorLength { compositorCursorIndex += 1 @@ -727,17 +727,14 @@ extension KeyHandler { stateCallback(state) } } else if input.isOptionHold { - if compositorCursorIndex > 1 { - compositorCursorIndex -= 2 - stateCallback(buildInputtingState) - } else if compositorCursorIndex == 1 { - compositorCursorIndex = 0 - stateCallback(buildInputtingState) - } else { + // 游標跳轉動作無論怎樣都會執行,但如果出了執行失敗的結果的話則觸發報錯流程。 + if !compositor.jumpCursorBySpan(to: .rear) { IME.prtDebugIntel("8D50DD9E") errorCallback() stateCallback(state) + return true } + stateCallback(buildInputtingState) } else { if compositorCursorIndex > 0 { compositorCursorIndex -= 1