KeyHandler // Stop cursor from cutting chars.
This commit is contained in:
parent
02abb79668
commit
8d4530b8c3
|
@ -49,6 +49,8 @@ protocol KeyHandlerDelegate {
|
||||||
class KeyHandler {
|
class KeyHandler {
|
||||||
/// 半衰模組的衰減指數
|
/// 半衰模組的衰減指數
|
||||||
let kEpsilon: Double = 0.000001
|
let kEpsilon: Double = 0.000001
|
||||||
|
/// 檢測是否出現游標切斷組字圈內字符的情況
|
||||||
|
var isCursorCuttingChar = false
|
||||||
|
|
||||||
/// 規定最大動態爬軌範圍。組字器內超出該範圍的節錨都會被自動標記為「已經手動選字過」,減少爬軌運算負擔。
|
/// 規定最大動態爬軌範圍。組字器內超出該範圍的節錨都會被自動標記為「已經手動選字過」,減少爬軌運算負擔。
|
||||||
let kMaxComposingBufferNeedsToWalkSize = Int(max(12, ceil(Double(mgrPrefs.composingBufferSize) / 2)))
|
let kMaxComposingBufferNeedsToWalkSize = Int(max(12, ceil(Double(mgrPrefs.composingBufferSize) / 2)))
|
||||||
|
|
|
@ -156,7 +156,11 @@ extension KeyHandler {
|
||||||
|
|
||||||
/// 給工具提示設定提示配色。
|
/// 給工具提示設定提示配色。
|
||||||
if !stateResult.tooltip.isEmpty {
|
if !stateResult.tooltip.isEmpty {
|
||||||
|
isCursorCuttingChar = true
|
||||||
ctlInputMethod.tooltipController.setColor(state: .denialOverflow)
|
ctlInputMethod.tooltipController.setColor(state: .denialOverflow)
|
||||||
|
} else {
|
||||||
|
isCursorCuttingChar = false
|
||||||
|
ctlInputMethod.tooltipController.setColor(state: .normal)
|
||||||
}
|
}
|
||||||
|
|
||||||
return stateResult
|
return stateResult
|
||||||
|
@ -659,6 +663,7 @@ extension KeyHandler {
|
||||||
stateCallback(state)
|
stateCallback(state)
|
||||||
}
|
}
|
||||||
} else if input.isOptionHold {
|
} else if input.isOptionHold {
|
||||||
|
isCursorCuttingChar = false
|
||||||
if input.isControlHold {
|
if input.isControlHold {
|
||||||
return handleEnd(state: state, stateCallback: stateCallback, errorCallback: errorCallback)
|
return handleEnd(state: state, stateCallback: stateCallback, errorCallback: errorCallback)
|
||||||
}
|
}
|
||||||
|
@ -673,7 +678,12 @@ extension KeyHandler {
|
||||||
} else {
|
} else {
|
||||||
if compositor.cursor < compositor.length {
|
if compositor.cursor < compositor.length {
|
||||||
compositor.cursor += 1
|
compositor.cursor += 1
|
||||||
stateCallback(buildInputtingState)
|
var inputtingState = buildInputtingState
|
||||||
|
if isCursorCuttingChar == true {
|
||||||
|
compositor.jumpCursorBySpan(to: .front)
|
||||||
|
inputtingState = buildInputtingState
|
||||||
|
}
|
||||||
|
stateCallback(inputtingState)
|
||||||
} else {
|
} else {
|
||||||
IME.prtDebugIntel("A96AAD58")
|
IME.prtDebugIntel("A96AAD58")
|
||||||
errorCallback()
|
errorCallback()
|
||||||
|
@ -727,6 +737,7 @@ extension KeyHandler {
|
||||||
stateCallback(state)
|
stateCallback(state)
|
||||||
}
|
}
|
||||||
} else if input.isOptionHold {
|
} else if input.isOptionHold {
|
||||||
|
isCursorCuttingChar = false
|
||||||
if input.isControlHold {
|
if input.isControlHold {
|
||||||
return handleHome(state: state, stateCallback: stateCallback, errorCallback: errorCallback)
|
return handleHome(state: state, stateCallback: stateCallback, errorCallback: errorCallback)
|
||||||
}
|
}
|
||||||
|
@ -741,7 +752,12 @@ extension KeyHandler {
|
||||||
} else {
|
} else {
|
||||||
if compositor.cursor > 0 {
|
if compositor.cursor > 0 {
|
||||||
compositor.cursor -= 1
|
compositor.cursor -= 1
|
||||||
stateCallback(buildInputtingState)
|
var inputtingState = buildInputtingState
|
||||||
|
if isCursorCuttingChar == true {
|
||||||
|
compositor.jumpCursorBySpan(to: .rear)
|
||||||
|
inputtingState = buildInputtingState
|
||||||
|
}
|
||||||
|
stateCallback(inputtingState)
|
||||||
} else {
|
} else {
|
||||||
IME.prtDebugIntel("7045E6F3")
|
IME.prtDebugIntel("7045E6F3")
|
||||||
errorCallback()
|
errorCallback()
|
||||||
|
|
Loading…
Reference in New Issue