UserDef // +kMinCellWidthForHorizontalMatrix.

This commit is contained in:
ShikiSuen 2024-03-10 12:46:13 +08:00
parent 5a6aee2a25
commit 9e1d130ba7
10 changed files with 34 additions and 1 deletions

View File

@ -19,6 +19,7 @@ public class CandidateCellData: Hashable {
public static var unifiedSize: Double = 16
public static var unifiedCharDimension: Double { ceil(unifiedSize * 1.0125 + 7) }
public static var unifiedTextHeight: Double { ceil(unifiedSize * 19 / 16) }
static var internalPrefs = PrefMgr()
public var selectionKey: String
public let displayedText: String
public private(set) var textDimension: NSSize
@ -81,7 +82,8 @@ public class CandidateCellData: Hashable {
}
public func cellLength(isMatrix: Bool = true) -> Double {
let minLength = ceil(Self.unifiedCharDimension * 2 + size * 1.25)
let factor: CGFloat = (Self.internalPrefs.minCellWidthForHorizontalMatrix == 0) ? 1.5 : 2
let minLength = ceil(Self.unifiedCharDimension * factor + size * 1.25)
if displayedText.count <= 2, isMatrix { return minLength }
return textDimension.width
}

View File

@ -37,6 +37,7 @@ public extension SettingsPanesCocoa {
}
UserDef.kCandidateWindowShowOnlyOneLine.render(fixWidth: innerContentWidth)
UserDef.kAlwaysExpandCandidateWindow.render(fixWidth: innerContentWidth)
UserDef.kMinCellWidthForHorizontalMatrix.render(fixWidth: innerContentWidth)
UserDef.kRespectClientAccentColor.render(fixWidth: innerContentWidth)
}?.boxed()
NSView()

View File

@ -26,6 +26,9 @@ public struct VwrSettingsPaneCandidates: View {
@AppStorage(wrappedValue: true, UserDef.kRespectClientAccentColor.rawValue)
private var respectClientAccentColor: Bool
@AppStorage(wrappedValue: 0, UserDef.kMinCellWidthForHorizontalMatrix.rawValue)
private var minCellWidthForHorizontalMatrix: Int
@AppStorage(wrappedValue: false, UserDef.kAlwaysExpandCandidateWindow.rawValue)
private var alwaysExpandCandidateWindow: Bool
@ -102,6 +105,8 @@ public struct VwrSettingsPaneCandidates: View {
if !candidateWindowShowOnlyOneLine {
UserDef.kAlwaysExpandCandidateWindow.bind($alwaysExpandCandidateWindow).render()
.disabled(candidateWindowShowOnlyOneLine)
UserDef.kMinCellWidthForHorizontalMatrix.bind($minCellWidthForHorizontalMatrix).render()
.disabled(candidateWindowShowOnlyOneLine)
}
UserDef.kRespectClientAccentColor.bind($respectClientAccentColor).render()
}

View File

@ -149,6 +149,9 @@ import SwiftExtension
@AppProperty(key: UserDef.kUseHorizontalCandidateList.rawValue, defaultValue: true)
public dynamic var useHorizontalCandidateList: Bool
@AppProperty(key: UserDef.kMinCellWidthForHorizontalMatrix.rawValue, defaultValue: 0)
public dynamic var minCellWidthForHorizontalMatrix: Int
@AppProperty(key: UserDef.kChooseCandidateUsingSpace.rawValue, defaultValue: true)
public dynamic var chooseCandidateUsingSpace: Bool

View File

@ -37,6 +37,7 @@ public protocol PrefMgrProtocol {
var dodgeInvalidEdgeCandidateCursorPosition: Bool { get set }
var useDynamicCandidateWindowOrigin: Bool { get set }
var useHorizontalCandidateList: Bool { get set }
var minCellWidthForHorizontalMatrix: Int { get set }
var chooseCandidateUsingSpace: Bool { get set }
var allowBoostingSingleKanjiAsUserPhrase: Bool { get set }
var fetchSuggestionsFromUserOverrideModel: Bool { get set }

View File

@ -57,6 +57,7 @@ public enum UserDef: String, CaseIterable, Identifiable {
case kUseShiftQuestionToCallServiceMenu = "UseShiftQuestionToCallServiceMenu"
case kUseDynamicCandidateWindowOrigin = "UseDynamicCandidateWindowOrigin"
case kUseHorizontalCandidateList = "UseHorizontalCandidateList"
case kMinCellWidthForHorizontalMatrix = "MinCellWidthForHorizontalMatrix"
case kChooseCandidateUsingSpace = "ChooseCandidateUsingSpace"
case kCassetteEnabled = "CassetteEnabled"
case kCNS11643Enabled = "CNS11643Enabled"
@ -184,6 +185,7 @@ public extension UserDef {
case .kUseShiftQuestionToCallServiceMenu: return .bool
case .kUseDynamicCandidateWindowOrigin: return .bool
case .kUseHorizontalCandidateList: return .bool
case .kMinCellWidthForHorizontalMatrix: return .integer
case .kChooseCandidateUsingSpace: return .bool
case .kCassetteEnabled: return .bool
case .kCNS11643Enabled: return .bool
@ -358,6 +360,13 @@ public extension UserDef {
description: "Choose your preferred layout of the candidate window.",
options: [0: "Vertical", 1: "Horizontal"]
)
case .kMinCellWidthForHorizontalMatrix: return .init(
userDef: self, shortTitle: "i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle",
options: [
0: "i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0",
1: "i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1",
]
)
case .kChooseCandidateUsingSpace: return .init(
userDef: self, shortTitle: "Enable Space key for calling candidate window",
description: "If disabled, this will insert space instead."

View File

@ -224,6 +224,9 @@
"i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "Dodge Invalid Edge Candidate Cursor Position";
"i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "Filter Non-CNS11643 factory readings (CHT input only)";
"i18n:UserDef.kInlineDumpPinyinInLieuOfZhuyin.description" = "Contents committed by Command+Option+Ctrl+Enter may vary depending on related behavior settings.";
"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0" = "2 Kanjis";
"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1" = "2 Emojis (Wider)";
"i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle" = "Minimum cell width for horizontal matrix:";
"i18n:UserDef.kNumPadCharInputBehavior.description" = "Choose the behavior of numeric pad inputs.";
"i18n:UserDef.kNumPadCharInputBehavior.option.0" = "Always directly commit half-width chars";
"i18n:UserDef.kNumPadCharInputBehavior.option.1" = "Always directly commit full-width chars";

View File

@ -224,6 +224,9 @@
"i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "端末での不合理的な候補選択用カーソル位置を是正";
"i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "全字庫以外の音読みを内蔵辞書繁体中国語検索結果から除く";
"i18n:UserDef.kInlineDumpPinyinInLieuOfZhuyin.description" = "Command+Option+Ctrl+Enter で送り出したものは、それに関する作動設定次第です。";
"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0" = "2つの漢字(幅の狭い)";
"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1" = "2つの絵文字(幅の広い)";
"i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle" = "多行横型陳列ウィンドウの候補の最小幅:";
"i18n:UserDef.kNumPadCharInputBehavior.description" = "テンキー文字の入力行為をご指定ください。";
"i18n:UserDef.kNumPadCharInputBehavior.option.0" = "いつでも半角で直接出力";
"i18n:UserDef.kNumPadCharInputBehavior.option.1" = "いつでも全角で直接出力";

View File

@ -224,6 +224,9 @@
"i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "糾正不合理的端点选字游标位置";
"i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "仅繁体中文: 原厂辞典仅返回符合全字库读音的结果";
"i18n:UserDef.kInlineDumpPinyinInLieuOfZhuyin.description" = "借由 Command+Option+Ctrl+Enter 输出的内容受对应的行为设定所影响。";
"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0" = "两个汉字";
"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1" = "两个绘文字(更宽)";
"i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle" = "横向多列选字窗最低单元宽度:";
"i18n:UserDef.kNumPadCharInputBehavior.description" = "指定数字小键盘的输入行为。";
"i18n:UserDef.kNumPadCharInputBehavior.option.0" = "始终以半形文字直接递交";
"i18n:UserDef.kNumPadCharInputBehavior.option.1" = "始终以全形文字直接递交";

View File

@ -224,6 +224,9 @@
"i18n:UserDef.kDodgeInvalidEdgeCandidateCursorPosition.shortTitle" = "糾正不合理的端點選字游標位置";
"i18n:UserDef.kFilterNonCNSReadingsForCHTInput.shortTitle" = "僅繁體中文: 原廠辭典僅返回符合全字庫讀音的結果";
"i18n:UserDef.kInlineDumpPinyinInLieuOfZhuyin.description" = "藉由 Command+Option+Ctrl+Enter 輸出的內容受對應的行為設定所影響。";
"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.0" = "兩個漢字";
"i18n:UserDef.kMinCellWidthForHorizontalMatrix.option.1" = "兩個繪文字(更寬)";
"i18n:userdef.kMinCellWidthForHorizontalMatrix.shortTitle" = "橫向多列選字窗最低單元寬度:";
"i18n:UserDef.kNumPadCharInputBehavior.description" = "指定數字小鍵盤的輸入行為。";
"i18n:UserDef.kNumPadCharInputBehavior.option.0" = "始終以半形文字直接遞交";
"i18n:UserDef.kNumPadCharInputBehavior.option.1" = "始終以全形文字直接遞交";