InputHandler // Fix markers for .ofCandidates().
This commit is contained in:
parent
3c8fe42f9f
commit
a7e3013a1f
|
@ -428,10 +428,18 @@ public class InputHandler: InputHandlerProtocol {
|
||||||
preConsolidate: PrefMgr.shared.consolidateContextOnCandidateSelection,
|
preConsolidate: PrefMgr.shared.consolidateContextOnCandidateSelection,
|
||||||
skipObservation: true
|
skipObservation: true
|
||||||
)
|
)
|
||||||
let inputting = generateStateOfInputting(sansReading: true)
|
theState.data.displayTextSegments = compositor.walkedNodes.values
|
||||||
theState.data.displayTextSegments = inputting.data.displayTextSegments
|
theState.data.cursor = convertCursorForDisplay(compositor.cursor)
|
||||||
theState.data.cursor = inputting.cursor
|
let markerBackup = compositor.marker
|
||||||
theState.data.marker = inputting.marker
|
if compositor.cursor == compositor.length {
|
||||||
|
compositor.jumpCursorBySpan(to: .rear, isMarker: true)
|
||||||
|
} else if compositor.cursor == 0 {
|
||||||
|
compositor.jumpCursorBySpan(to: .front, isMarker: true)
|
||||||
|
} else {
|
||||||
|
compositor.jumpCursorBySpan(to: prefs.useRearCursorMode ? .front : .rear, isMarker: true)
|
||||||
|
}
|
||||||
|
theState.data.marker = compositor.marker
|
||||||
|
compositor.marker = markerBackup
|
||||||
delegate.state = theState // 直接就地取代,不經過 switchState 處理,免得選字窗被重新載入。
|
delegate.state = theState // 直接就地取代,不經過 switchState 處理,免得選字窗被重新載入。
|
||||||
delegate.setInlineDisplayWithCursor()
|
delegate.setInlineDisplayWithCursor()
|
||||||
delegate.updatePopupDisplayWithCursor()
|
delegate.updatePopupDisplayWithCursor()
|
||||||
|
|
|
@ -124,11 +124,18 @@ extension InputHandler {
|
||||||
/// 拿著給定的候選字詞陣列資料內容,切換至選字狀態。
|
/// 拿著給定的候選字詞陣列資料內容,切換至選字狀態。
|
||||||
/// - Returns: 回呼一個新的選詞狀態,來就給定的候選字詞陣列資料內容顯示選字窗。
|
/// - Returns: 回呼一個新的選詞狀態,來就給定的候選字詞陣列資料內容顯示選字窗。
|
||||||
public func generateStateOfCandidates() -> IMEStateProtocol {
|
public func generateStateOfCandidates() -> IMEStateProtocol {
|
||||||
IMEState.ofCandidates(
|
var result = IMEState.ofCandidates(
|
||||||
candidates: generateArrayOfCandidates(fixOrder: prefs.useFixecCandidateOrderOnSelection),
|
candidates: generateArrayOfCandidates(fixOrder: prefs.useFixecCandidateOrderOnSelection),
|
||||||
displayTextSegments: compositor.walkedNodes.values,
|
displayTextSegments: compositor.walkedNodes.values,
|
||||||
cursor: delegate?.state.cursor ?? generateStateOfInputting().cursor
|
cursor: delegate?.state.cursor ?? generateStateOfInputting().cursor
|
||||||
)
|
)
|
||||||
|
if !prefs.useRearCursorMode {
|
||||||
|
let markerBackup = compositor.marker
|
||||||
|
compositor.jumpCursorBySpan(to: .rear, isMarker: true)
|
||||||
|
result.marker = compositor.marker
|
||||||
|
compositor.marker = markerBackup
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 用以接收聯想詞陣列且生成狀態
|
// MARK: - 用以接收聯想詞陣列且生成狀態
|
||||||
|
|
Loading…
Reference in New Issue