PhraseEditor // Add tooltip to the main edit area.

This commit is contained in:
ShikiSuen 2022-12-09 14:17:55 +08:00
parent 5bbc4edf33
commit a9c7d0c12d
7 changed files with 43 additions and 3 deletions

View File

@ -43,6 +43,7 @@ public struct VwrPhraseEditorUI: View {
@State public var selInputMode: Shared.InputMode = .imeModeNULL
@State public var selUserDataType: vChewingLM.ReplacableUserDataType = .thePhrases
@State private var isLoading = false
@State private var textEditorTooltip = PETerms.TooltipTexts.sampleDictionaryContent(for: .thePhrases)
public var currentIMEInputMode: Shared.InputMode {
delegate?.currentInputMode ?? selInputMode
@ -78,6 +79,7 @@ public struct VwrPhraseEditorUI: View {
isLoading = true
DispatchQueue.main.async {
txtContent = delegate.retrieveData(mode: selInputMode, type: selUserDataType)
textEditorTooltip = PETerms.TooltipTexts.sampleDictionaryContent(for: selUserDataType)
isLoading = false
}
}
@ -246,7 +248,7 @@ public struct VwrPhraseEditorUI: View {
}
}
TextEditorEX(text: $txtContent)
TextEditorEX(text: $txtContent, tooltip: $textEditorTooltip)
.disabled(selInputMode == .imeModeNULL || isLoading)
.frame(minWidth: 320, minHeight: 240)
.backport.onChange(of: fileChangeIndicator.id) { _ in
@ -340,6 +342,22 @@ public enum PETerms {
case weightInputBox =
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result."
public static func sampleDictionaryContent(for type: vChewingLM.ReplacableUserDataType) -> String {
var result = ""
switch type {
case .thePhrases:
result =
"Example:\nCandidate Reading-Reading Weight #Comment\nCandidate Reading-Reading #Comment".localized + "\n\n"
+ weightInputBox.localized
case .theFilter: result = "Example:\nCandidate Reading-Reading #Comment".localized
case .theReplacements: result = "Example:\nOldPhrase NewPhrase #Comment".localized
case .theAssociates:
result = "Example:\nInitial RestPhrase\nInitial RestPhrase1 RestPhrase2 RestPhrase3...".localized
case .theSymbols: result = "Example:\nCandidate Reading-Reading #Comment".localized
}
return result
}
public var localized: String { rawValue.localized }
}
}

View File

@ -40,6 +40,7 @@ extension CtlPrefWindow: NSTextViewDelegate, NSTextFieldDelegate {
tfdPETextEditor.string = NSLocalizedString("Loading…", comment: "")
DispatchQueue.main.async { [self] in
tfdPETextEditor.string = LMMgr.retrieveData(mode: selInputMode, type: selUserDataType)
tfdPETextEditor.toolTip = PETerms.TooltipTexts.sampleDictionaryContent(for: selUserDataType)
isLoading = false
}
}
@ -157,6 +158,7 @@ extension CtlPrefWindow: NSTextViewDelegate, NSTextFieldDelegate {
// Tooltip.
txtPEField3.toolTip = PETerms.TooltipTexts.weightInputBox.localized
tfdPETextEditor.toolTip = PETerms.TooltipTexts.sampleDictionaryContent(for: selUserDataType)
// Finally, update the entire editor UI.
updatePhraseEditor()

View File

@ -16,6 +16,10 @@
"Loading…" = "Loading…";
"Consolidate" = "Consolidate";
"Reload" = "Reload";
"Example:\nCandidate Reading-Reading #Comment" = "Example:\nCandidate Reading-Reading #Comment";
"Example:\nCandidate Reading-Reading Weight #Comment\nCandidate Reading-Reading #Comment" = "Example:\nCandidate Reading-Reading Weight #Comment\nCandidate Reading-Reading #Comment";
"Example:\nInitial RestPhrase\nInitial RestPhrase1 RestPhrase2 RestPhrase3..." = "Example:\nInitial RestPhrase\nInitial RestPhrase1 RestPhrase2 RestPhrase3...";
"Example:\nOldPhrase NewPhrase #Comment" = "Example:\nOldPhrase NewPhrase #Comment";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result.";
"Factory dictionary not loaded yet." = "Factory dictionary not loaded yet.";
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations.";

View File

@ -16,6 +16,10 @@
"Loading…" = "Loading…";
"Consolidate" = "Consolidate";
"Reload" = "Reload";
"Example:\nCandidate Reading-Reading #Comment" = "Example:\nCandidate Reading-Reading #Comment";
"Example:\nCandidate Reading-Reading Weight #Comment\nCandidate Reading-Reading #Comment" = "Example:\nCandidate Reading-Reading Weight #Comment\nCandidate Reading-Reading #Comment";
"Example:\nInitial RestPhrase\nInitial RestPhrase1 RestPhrase2 RestPhrase3..." = "Example:\nInitial RestPhrase\nInitial RestPhrase1 RestPhrase2 RestPhrase3...";
"Example:\nOldPhrase NewPhrase #Comment" = "Example:\nOldPhrase NewPhrase #Comment";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result.";
"Factory dictionary not loaded yet." = "Factory dictionary not loaded yet.";
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations.";

View File

@ -16,6 +16,10 @@
"Loading…" = "読み込む中…";
"Consolidate" = "整理";
"Reload" = "再読込";
"Example:\nCandidate Reading-Reading #Comment" = "【模範例】\n候補 音読-音読 #メモ";
"Example:\nCandidate Reading-Reading Weight #Comment\nCandidate Reading-Reading #Comment" = "【模範例】\n候補 音読-音読 優先度 #メモ\n候補 音読-音読 #メモ";
"Example:\nInitial RestPhrase\nInitial RestPhrase1 RestPhrase2 RestPhrase3..." = "【模範例】\n頭文字 残候補\n頭文字 残候補1 残候補2 残候補3...";
"Example:\nOldPhrase NewPhrase #Comment" = "【模範例】\n置換対象 新候補 #メモ";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "優先度を記入しなかった場合、最高値「0」はデフォルト値です。理想な優先度の範囲は [-9.5, 0] 以内で、ウォーキング算法に捕まれられます。例外は懲戒値「-114.514」で、優先度を最低に極めた値であり、唯一結果のない場合、ウォーキング算法に無視されます。";
"Factory dictionary not loaded yet." = "内蔵辞書はまだ読込中。";
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "システム API 制限のため、一部の機能は macOS 10.15 と macOS 11 で提供できません。";

View File

@ -16,7 +16,11 @@
"Loading…" = "正在载入…";
"Consolidate" = "整理";
"Reload" = "重新载入";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填写权重的话预设权重为最高值「0」。理想的权重范围在 [-9.5, 0] 这个闭区间内,可以被爬轨引擎自动抓到。例外就是惩戒权重「-114.514」,属于极端降权。这种情况下,除非是唯一结果,否则会被爬轨引擎无视。";
"Example:\nCandidate Reading-Reading #Comment" = "【范例】\n候选字词 读音-读音 #注解";
"Example:\nCandidate Reading-Reading Weight #Comment\nCandidate Reading-Reading #Comment" = "【范例】\n候选字词 读音-读音 权重 #注解\n候选字词 读音-读音 #注解";
"Example:\nInitial RestPhrase\nInitial RestPhrase1 RestPhrase2 RestPhrase3..." = "【范例】\n首字 候选\n首字 候选1 候选2 候选3...";
"Example:\nOldPhrase NewPhrase #Comment" = "【范例】\n要替换的词 替换成的词 #注解";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填写权重的话预设权重为最高值「0」。理想的权重范围在 [-9.5, 0] 这个闭区间内,可以被爬轨算法自动抓到。例外就是惩戒权重「-114.514」,属于极端降权。这种情况下,除非是唯一结果,否则会被爬轨算法忽略掉。";
"Factory dictionary not loaded yet." = "原厂辞典尚未完成载入。";
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "因系统 API 限制,个别功能无法对 macOS 10.15 和 macOS 11 提供。";
"This editor only: Auto-reload modifications happened outside of this editor" = "仅限该编辑器:自动读入来自该编辑器外部的档案内容修改";

View File

@ -16,7 +16,11 @@
"Loading…" = "正在載入…";
"Consolidate" = "整理";
"Reload" = "重新載入";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填寫權重的話預設權重為最高值「0」。理想的權重範圍在 [-9.5, 0] 這個閉區間內,可以被爬軌引擎自動抓到。例外就是懲戒權重「-114.514」,屬於極端降權。這種情況下,除非是唯一結果,否則會被爬軌引擎無視。";
"Example:\nCandidate Reading-Reading #Comment" = "【範例】\n候選字詞 讀音-讀音 #註解";
"Example:\nCandidate Reading-Reading Weight #Comment\nCandidate Reading-Reading #Comment" = "【範例】\n候選字詞 讀音-讀音 權重 #註解\n候選字詞 讀音-讀音 #註解";
"Example:\nInitial RestPhrase\nInitial RestPhrase1 RestPhrase2 RestPhrase3..." = "【範例】\n首字 候選\n首字 候選1 候選2 候選3...";
"Example:\nOldPhrase NewPhrase #Comment" = "【範例】\n要替換的詞 替換成的詞 #註解";
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填寫權重的話預設權重為最高值「0」。理想的權重範圍在 [-9.5, 0] 這個閉區間內,可以被爬軌算法自動抓到。例外就是懲戒權重「-114.514」,屬於極端降權。這種情況下,除非是唯一結果,否則會被爬軌算法忽略掉。";
"Factory dictionary not loaded yet." = "原廠辭典尚未完成載入。";
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "因系統 API 限制,個別功能無法對 macOS 10.15 和 macOS 11 提供。";
"This editor only: Auto-reload modifications happened outside of this editor" = "僅限該編輯器:自動讀入來自該編輯器外部的檔案內容修改";