KeyHandler // Switch candidates by Shift(+CMD)+Space.

This commit is contained in:
ShikiSuen 2022-06-16 14:46:02 +08:00
parent d2da05a267
commit ab62321f7a
2 changed files with 13 additions and 8 deletions

View File

@ -247,7 +247,7 @@ extension KeyHandler {
{ {
if input.isSpace { if input.isSpace {
// If the Space key is NOT set to be a selection key // If the Space key is NOT set to be a selection key
if input.isShiftHold || !mgrPrefs.chooseCandidateUsingSpace { if !mgrPrefs.chooseCandidateUsingSpace {
if compositorCursorIndex >= compositorLength { if compositorCursorIndex >= compositorLength {
let composingBuffer = currentState.composingBuffer let composingBuffer = currentState.composingBuffer
if !composingBuffer.isEmpty { if !composingBuffer.isEmpty {
@ -264,6 +264,11 @@ extension KeyHandler {
stateCallback(inputting) stateCallback(inputting)
} }
return true return true
} else if input.isShiftHold { // Tab Shift+CMD+Space /
return handleInlineCandidateRotation(
state: state, reverseModifier: input.isCommandHold, stateCallback: stateCallback,
errorCallback: errorCallback
)
} }
} }
stateCallback(buildCandidate(state: currentState, isTypingVertical: input.isTypingVertical)) stateCallback(buildCandidate(state: currentState, isTypingVertical: input.isTypingVertical))
@ -279,8 +284,8 @@ extension KeyHandler {
// MARK: Tab // MARK: Tab
if input.isTab { if input.isTab {
return handleTab( return handleInlineCandidateRotation(
state: state, isShiftHold: input.isShiftHold, stateCallback: stateCallback, errorCallback: errorCallback state: state, reverseModifier: input.isShiftHold, stateCallback: stateCallback, errorCallback: errorCallback
) )
} }

View File

@ -642,11 +642,11 @@ extension KeyHandler {
return true return true
} }
// MARK: - Tab // MARK: - Tab Shift+Space
func handleTab( func handleInlineCandidateRotation(
state: InputState, state: InputState,
isShiftHold: Bool, reverseModifier: Bool,
stateCallback: @escaping (InputState) -> Void, stateCallback: @escaping (InputState) -> Void,
errorCallback: @escaping () -> Void errorCallback: @escaping () -> Void
) -> Bool { ) -> Bool {
@ -709,7 +709,7 @@ extension KeyHandler {
if candidates[0] == currentValue { if candidates[0] == currentValue {
// If the first candidate is the value of the // If the first candidate is the value of the
// current node, we use next one. // current node, we use next one.
if isShiftHold { if reverseModifier {
currentIndex = candidates.count - 1 currentIndex = candidates.count - 1
} else { } else {
currentIndex = 1 currentIndex = 1
@ -718,7 +718,7 @@ extension KeyHandler {
} else { } else {
for candidate in candidates { for candidate in candidates {
if candidate == currentValue { if candidate == currentValue {
if isShiftHold { if reverseModifier {
if currentIndex == 0 { if currentIndex == 0 {
currentIndex = candidates.count - 1 currentIndex = candidates.count - 1
} else { } else {