From 6963784e59b037fda0f3f5dd220498aedfd4c4be Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sun, 7 May 2023 23:42:57 +0800 Subject: [PATCH] InputHander // Show tooltip for standalone intonation marks. --- .../NSAttributedTextView.swift | 2 ++ .../Modules/InputHandler_HandleComposition.swift | 6 +++++- Source/Modules/InputHandler_HandleStates.swift | 16 +++++++++++++++- Source/Resources/Base.lproj/Localizable.strings | 2 ++ Source/Resources/en.lproj/Localizable.strings | 2 ++ Source/Resources/ja.lproj/Localizable.strings | 2 ++ .../Resources/zh-Hans.lproj/Localizable.strings | 2 ++ .../Resources/zh-Hant.lproj/Localizable.strings | 2 ++ 8 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift b/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift index 6afdd087..971eee52 100644 --- a/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift +++ b/Packages/Fuziki_NSAttributedTextView/Sources/NSAttributedTextView/NSAttributedTextView.swift @@ -167,12 +167,14 @@ public class NSAttributedTooltipTextView: NSAttributedTextView { text = text.replacingOccurrences(of: "Command", with: "⌘") text = text.replacingOccurrences(of: "Delete", with: "⌦") text = text.replacingOccurrences(of: "BackSpace", with: "⌫") + text = text.replacingOccurrences(of: "Space", with: "␣") text = text.replacingOccurrences(of: "SHIFT", with: "⇧") text = text.replacingOccurrences(of: "CONTROL", with: "⌃") text = text.replacingOccurrences(of: "ENTER", with: "⏎") text = text.replacingOccurrences(of: "COMMAND", with: "⌘") text = text.replacingOccurrences(of: "DELETE", with: "⌦") text = text.replacingOccurrences(of: "BACKSPACE", with: "⌫") + text = text.replacingOccurrences(of: "SPACE", with: "␣") } if areaCalculation { text = text.replacingOccurrences( diff --git a/Source/Modules/InputHandler_HandleComposition.swift b/Source/Modules/InputHandler_HandleComposition.swift index ea706d81..dc99cd52 100644 --- a/Source/Modules/InputHandler_HandleComposition.swift +++ b/Source/Modules/InputHandler_HandleComposition.swift @@ -184,7 +184,11 @@ extension InputHandler { return nil } // 以回呼組字狀態的方式來執行 setInlineDisplayWithCursor()。 - delegate.switchState(generateStateOfInputting()) + var resultState = generateStateOfInputting() + resultState.tooltip = tooltipForStandaloneIntonationMark + resultState.tooltipDuration = 0 + resultState.data.tooltipColorState = .prompt + delegate.switchState(resultState) return true } return nil diff --git a/Source/Modules/InputHandler_HandleStates.swift b/Source/Modules/InputHandler_HandleStates.swift index d7830f61..9e5672e9 100644 --- a/Source/Modules/InputHandler_HandleStates.swift +++ b/Source/Modules/InputHandler_HandleStates.swift @@ -68,7 +68,21 @@ extension InputHandler { ) } - /// 生成「正在輸入」狀態。 + /// 生成「在有單獨的前置聲調符號輸入時」的工具提示。 + var tooltipForStandaloneIntonationMark: String { + guard !isComposerUsingPinyin else { return "" } + guard composer.hasIntonation(withNothingElse: true) else { return "" } + guard composer.intonation.value != " " else { return "" } + let result = NSMutableString() + result.append("Intonation mark. ENTER to commit.\nSPACE to insert into composition buffer.".localized) + if prefs.acceptLeadingIntonations { + result.append("\n") + result.append("It will attempt to combine with the incoming phonabet input.".localized) + } + return result.description + } + + /// 將組字器內的游標位置資料轉換成可以正確顯示的游標位置資料。 /// - Parameter rawCursor: 原始游標。 /// - Returns: 用以顯示的游標。 func convertCursorForDisplay(_ rawCursor: Int) -> Int { diff --git a/Source/Resources/Base.lproj/Localizable.strings b/Source/Resources/Base.lproj/Localizable.strings index db617786..c8e8f7d7 100644 --- a/Source/Resources/Base.lproj/Localizable.strings +++ b/Source/Resources/Base.lproj/Localizable.strings @@ -1,4 +1,6 @@ "vChewing" = "vChewing"; +"It will attempt to combine with the incoming phonabet input." = "It will attempt to combine with the incoming phonabet input."; +"Intonation mark. ENTER to commit.\nSPACE to insert into composition buffer." = "Intonation mark. ENTER to commit.\nSPACE to insert into composition buffer."; "CHS / CHT Input Mode Switch" = "CHS / CHT Input Mode Switch"; "Switch to %@ Input Mode" = "Switch to %@ Input Mode"; "Target Input Mode Activation Required" = "Target Input Mode Activation Required"; diff --git a/Source/Resources/en.lproj/Localizable.strings b/Source/Resources/en.lproj/Localizable.strings index db617786..c8e8f7d7 100644 --- a/Source/Resources/en.lproj/Localizable.strings +++ b/Source/Resources/en.lproj/Localizable.strings @@ -1,4 +1,6 @@ "vChewing" = "vChewing"; +"It will attempt to combine with the incoming phonabet input." = "It will attempt to combine with the incoming phonabet input."; +"Intonation mark. ENTER to commit.\nSPACE to insert into composition buffer." = "Intonation mark. ENTER to commit.\nSPACE to insert into composition buffer."; "CHS / CHT Input Mode Switch" = "CHS / CHT Input Mode Switch"; "Switch to %@ Input Mode" = "Switch to %@ Input Mode"; "Target Input Mode Activation Required" = "Target Input Mode Activation Required"; diff --git a/Source/Resources/ja.lproj/Localizable.strings b/Source/Resources/ja.lproj/Localizable.strings index 1e83173b..6021c9fc 100644 --- a/Source/Resources/ja.lproj/Localizable.strings +++ b/Source/Resources/ja.lproj/Localizable.strings @@ -1,4 +1,6 @@ "vChewing" = "威注音入力アプリ"; +"It will attempt to combine with the incoming phonabet input." = "この音調は次の注音入力と組み合わす。"; +"Intonation mark. ENTER to commit.\nSPACE to insert into composition buffer." = "音調記号。ENTER で送り出す。\nSPACE で入力緩衝列に挿入。"; "CHS / CHT Input Mode Switch" = "簡体・繁体中国語入力の切り替え"; "Switch to %@ Input Mode" = "%@入力モードに切り替え"; "Target Input Mode Activation Required" = "関連の入力ソースの追加が必要"; diff --git a/Source/Resources/zh-Hans.lproj/Localizable.strings b/Source/Resources/zh-Hans.lproj/Localizable.strings index 52e160d9..46b7ebce 100644 --- a/Source/Resources/zh-Hans.lproj/Localizable.strings +++ b/Source/Resources/zh-Hans.lproj/Localizable.strings @@ -1,4 +1,6 @@ "vChewing" = "威注音输入法"; +"It will attempt to combine with the incoming phonabet input." = "该声调亦会尝试与接下来输入的注音相组合。"; +"Intonation mark. ENTER to commit.\nSPACE to insert into composition buffer." = "声调符号。敲 Enter 以递交。\n敲空格键以插入组字区。"; "CHS / CHT Input Mode Switch" = "简体/繁体中文输入模式切换"; "Switch to %@ Input Mode" = "切换至%@输入模式"; "Target Input Mode Activation Required" = "得启用对应的「輸入法」"; diff --git a/Source/Resources/zh-Hant.lproj/Localizable.strings b/Source/Resources/zh-Hant.lproj/Localizable.strings index 4cf513c0..040942a5 100644 --- a/Source/Resources/zh-Hant.lproj/Localizable.strings +++ b/Source/Resources/zh-Hant.lproj/Localizable.strings @@ -1,4 +1,6 @@ "vChewing" = "威注音輸入法"; +"It will attempt to combine with the incoming phonabet input." = "該聲調亦會嘗試與接下來輸入的注音相組合。"; +"Intonation mark. ENTER to commit.\nSPACE to insert into composition buffer." = "聲調符號。敲 Enter 以遞交。\n敲空格鍵以插入組字區。"; "CHS / CHT Input Mode Switch" = "簡體/繁體中文輸入模式切換"; "Switch to %@ Input Mode" = "切換至%@輸入模式"; "Target Input Mode Activation Required" = "得啟用對應的「輸入方式」";