From e6e99c52052ce40ef73597fa06a9c545410105cf Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 24 Feb 2023 13:29:51 +0800 Subject: [PATCH] InputHandler // Implement Alt+BkSp features. --- Source/Modules/InputHandler_HandleStates.swift | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/Modules/InputHandler_HandleStates.swift b/Source/Modules/InputHandler_HandleStates.swift index b5fc3a9d..387e24bb 100644 --- a/Source/Modules/InputHandler_HandleStates.swift +++ b/Source/Modules/InputHandler_HandleStates.swift @@ -401,12 +401,21 @@ extension InputHandler { if isCodePointInputMode { if !strCodePointBuffer.isEmpty { - strCodePointBuffer = strCodePointBuffer.dropLast(1).description - if !strCodePointBuffer.isEmpty { + func refreshState() { var updatedState = generateStateOfInputting() updatedState.tooltipDuration = 0 updatedState.tooltip = tooltipCodePointInputMode delegate.switchState(updatedState) + } + strCodePointBuffer = strCodePointBuffer.dropLast(1).description + if input.modifierFlags == .option { + strCodePointBuffer.removeAll() + refreshState() + isCodePointInputMode = true + return true + } + if !strCodePointBuffer.isEmpty { + refreshState() return true } } @@ -460,7 +469,9 @@ extension InputHandler { } walk() } else { - letComposerAndCalligrapherDoBackSpace() + _ = input.modifierFlags == .option + ? clearComposerAndCalligrapher() + : letComposerAndCalligrapherDoBackSpace() } switch isConsideredEmptyForNow {