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

View File

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