InputHandler // Add updateUnigramData().
This commit is contained in:
parent
9028c6a5dd
commit
3cc7972613
|
@ -32,6 +32,7 @@ public protocol InputHandlerProtocol {
|
|||
func generateStateOfInputting(sansReading: Bool) -> IMEStateProtocol
|
||||
func generateStateOfAssociates(withPair pair: Megrez.Compositor.KeyValuePaired) -> IMEStateProtocol
|
||||
func consolidateNode(candidate: (String, String), respectCursorPushing: Bool, preConsolidate: Bool)
|
||||
func updateUnigramData() -> Bool
|
||||
}
|
||||
|
||||
extension InputHandlerProtocol {
|
||||
|
@ -436,6 +437,13 @@ public class InputHandler: InputHandlerProtocol {
|
|||
|
||||
// MARK: - Extracted methods and functions (Megrez).
|
||||
|
||||
/// 就地增刪詞之後,需要就地更新游標上下文單元圖資料。
|
||||
public func updateUnigramData() -> Bool {
|
||||
let result = compositor.update(updateExisting: true)
|
||||
defer { walk() }
|
||||
return result > 0
|
||||
}
|
||||
|
||||
/// 生成標點符號索引鍵。
|
||||
/// - Parameter input: 輸入的按鍵訊號。
|
||||
/// - Returns: 生成的標點符號索引鍵。
|
||||
|
|
|
@ -156,7 +156,7 @@ extension SessionCtl: CtlCandidateDelegate {
|
|||
}
|
||||
|
||||
public func candidatePairRightClicked(at index: Int, action: CandidateContextMenuAction) {
|
||||
guard isCandidateContextMenuEnabled else { return }
|
||||
guard let inputHandler = inputHandler, isCandidateContextMenuEnabled else { return }
|
||||
var succeeded = true
|
||||
|
||||
let rawPair = state.candidates[index]
|
||||
|
@ -185,9 +185,11 @@ extension SessionCtl: CtlCandidateDelegate {
|
|||
// 開始針對使用者半衰模組的清詞處理
|
||||
LMMgr.bleachSpecifiedSuggestions(targets: [valueCurrent], mode: IMEApp.currentInputMode)
|
||||
LMMgr.bleachSpecifiedSuggestions(targets: [valueReversed], mode: IMEApp.currentInputMode.reversed)
|
||||
// 更新組字器內的單元圖資料。
|
||||
let updateResult = inputHandler.updateUnigramData(key: rawPair.0)
|
||||
// 清詞完畢
|
||||
|
||||
var newState = IMEState.ofCommitting(textToCommit: state.displayedText)
|
||||
var newState = inputHandler.generateStateOfInputting()
|
||||
newState.tooltipDuration = 1.85
|
||||
var tooltipMessage = ""
|
||||
switch action {
|
||||
|
|
Loading…
Reference in New Issue