PrefUI // Make tab pages scrollable if too large.

This commit is contained in:
ShikiSuen 2022-08-19 10:46:06 +08:00
parent 4af7ad6c9d
commit c5740fb204
5 changed files with 560 additions and 541 deletions

View File

@ -16,6 +16,8 @@ struct suiPrefPaneDevZone: View {
forKey: UserDef.kHandleDefaultCandidateFontsByLangIdentifier.rawValue) forKey: UserDef.kHandleDefaultCandidateFontsByLangIdentifier.rawValue)
@State private var selShouldAlwaysUseShiftKeyAccommodation: Bool = UserDefaults.standard.bool( @State private var selShouldAlwaysUseShiftKeyAccommodation: Bool = UserDefaults.standard.bool(
forKey: UserDef.kShouldAlwaysUseShiftKeyAccommodation.rawValue) forKey: UserDef.kShouldAlwaysUseShiftKeyAccommodation.rawValue)
private let contentMaxHeight: Double = 430
private let contentWidth: Double = { private let contentWidth: Double = {
switch mgrPrefs.appleLanguages[0] { switch mgrPrefs.appleLanguages[0] {
case "ja": case "ja":
@ -30,48 +32,50 @@ struct suiPrefPaneDevZone: View {
}() }()
var body: some View { var body: some View {
Preferences.Container(contentWidth: contentWidth) { ScrollView {
Preferences.Section(title: "", bottomDivider: true) { Preferences.Container(contentWidth: contentWidth) {
Text( Preferences.Section(title: "", bottomDivider: true) {
LocalizedStringKey( Text(
"Warning: This page is for testing future features. \nFeatures listed here may not work as expected.") LocalizedStringKey(
) "Warning: This page is for testing future features. \nFeatures listed here may not work as expected.")
.fixedSize(horizontal: false, vertical: true) )
Divider() .fixedSize(horizontal: false, vertical: true)
Toggle( Divider()
LocalizedStringKey("Use IMK Candidate Window instead (will reboot the IME)"), Toggle(
isOn: $selUseIMKCandidateWindow.onChange { LocalizedStringKey("Use IMK Candidate Window instead (will reboot the IME)"),
mgrPrefs.useIMKCandidateWindow = selUseIMKCandidateWindow isOn: $selUseIMKCandidateWindow.onChange {
} mgrPrefs.useIMKCandidateWindow = selUseIMKCandidateWindow
) }
Text(LocalizedStringKey("IMK candidate window is plagued with issues and incapabilities.")) )
Text(LocalizedStringKey("IMK candidate window is plagued with issues and incapabilities."))
.preferenceDescription().fixedSize(horizontal: false, vertical: true)
Toggle(
LocalizedStringKey("Use .langIdentifier to handle UI fonts in candidate window"),
isOn: $selHandleDefaultCandidateFontsByLangIdentifier.onChange {
mgrPrefs.handleDefaultCandidateFontsByLangIdentifier = selHandleDefaultCandidateFontsByLangIdentifier
}
)
Text(
LocalizedStringKey(
"This only works since macOS 12 with non-IMK candidate window as an alternative wordaround of Apple Bug Report #FB10978412. Apple should patch that for macOS 11 and later."
)
)
.preferenceDescription().fixedSize(horizontal: false, vertical: true) .preferenceDescription().fixedSize(horizontal: false, vertical: true)
Toggle( Toggle(
LocalizedStringKey("Use .langIdentifier to handle UI fonts in candidate window"), LocalizedStringKey("Use Shift Key Accommodation in all cases"),
isOn: $selHandleDefaultCandidateFontsByLangIdentifier.onChange { isOn: $selShouldAlwaysUseShiftKeyAccommodation.onChange {
mgrPrefs.handleDefaultCandidateFontsByLangIdentifier = selHandleDefaultCandidateFontsByLangIdentifier mgrPrefs.shouldAlwaysUseShiftKeyAccommodation = selShouldAlwaysUseShiftKeyAccommodation
} }
)
Text(
LocalizedStringKey(
"This only works since macOS 12 with non-IMK candidate window as an alternative wordaround of Apple Bug Report #FB10978412. Apple should patch that for macOS 11 and later."
) )
) Text(
.preferenceDescription().fixedSize(horizontal: false, vertical: true) LocalizedStringKey(
Toggle( "Some client apps (like Chromium-cored browsers: MS Edge, Google Chrome, etc.) may duplicate Shift-key inputs due to their internal bugs, and their devs are less likely to fix their bugs of such. vChewing has its accommodation procedures enabled by default for known Chromium-cored browsers. If you want the same accommodation for other client apps, please tick this checkbox on."
LocalizedStringKey("Use Shift Key Accommodation in all cases"), )
isOn: $selShouldAlwaysUseShiftKeyAccommodation.onChange {
mgrPrefs.shouldAlwaysUseShiftKeyAccommodation = selShouldAlwaysUseShiftKeyAccommodation
}
)
Text(
LocalizedStringKey(
"Some client apps (like Chromium-cored browsers: MS Edge, Google Chrome, etc.) may duplicate Shift-key inputs due to their internal bugs, and their devs are less likely to fix their bugs of such. vChewing has its accommodation procedures enabled by default for known Chromium-cored browsers. If you want the same accommodation for other client apps, please tick this checkbox on."
) )
) .preferenceDescription().fixedSize(horizontal: false, vertical: true)
.preferenceDescription().fixedSize(horizontal: false, vertical: true) }
} }
} }.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true)
} }
} }

View File

@ -25,6 +25,8 @@ struct suiPrefPaneDictionary: View {
forKey: UserDef.kFetchSuggestionsFromUserOverrideModel.rawValue) forKey: UserDef.kFetchSuggestionsFromUserOverrideModel.rawValue)
@State private var selUseFixecCandidateOrderOnSelection: Bool = UserDefaults.standard.bool( @State private var selUseFixecCandidateOrderOnSelection: Bool = UserDefaults.standard.bool(
forKey: UserDef.kUseFixecCandidateOrderOnSelection.rawValue) forKey: UserDef.kUseFixecCandidateOrderOnSelection.rawValue)
private let contentMaxHeight: Double = 430
private let contentWidth: Double = { private let contentWidth: Double = {
switch mgrPrefs.appleLanguages[0] { switch mgrPrefs.appleLanguages[0] {
case "ja": case "ja":
@ -39,109 +41,111 @@ struct suiPrefPaneDictionary: View {
}() }()
var body: some View { var body: some View {
Preferences.Container(contentWidth: contentWidth) { ScrollView {
Preferences.Section(title: "", bottomDivider: true) { Preferences.Container(contentWidth: contentWidth) {
Text(LocalizedStringKey("Choose your desired user data folder path. Will be omitted if invalid.")) Preferences.Section(title: "", bottomDivider: true) {
HStack { Text(LocalizedStringKey("Choose your desired user data folder path. Will be omitted if invalid."))
if #available(macOS 11.0, *) { HStack {
TextField(fdrDefault, text: $tbxUserDataPathSpecified).disabled(true) if #available(macOS 11.0, *) {
.help(tbxUserDataPathSpecified) TextField(fdrDefault, text: $tbxUserDataPathSpecified).disabled(true)
} else { .help(tbxUserDataPathSpecified)
TextField(fdrDefault, text: $tbxUserDataPathSpecified).disabled(true) } else {
.toolTip(tbxUserDataPathSpecified) TextField(fdrDefault, text: $tbxUserDataPathSpecified).disabled(true)
} .toolTip(tbxUserDataPathSpecified)
Button { }
IME.dlgOpenPath.title = NSLocalizedString( Button {
"Choose your desired user data folder.", comment: "" IME.dlgOpenPath.title = NSLocalizedString(
) "Choose your desired user data folder.", comment: ""
IME.dlgOpenPath.showsResizeIndicator = true )
IME.dlgOpenPath.showsHiddenFiles = true IME.dlgOpenPath.showsResizeIndicator = true
IME.dlgOpenPath.canChooseFiles = false IME.dlgOpenPath.showsHiddenFiles = true
IME.dlgOpenPath.canChooseDirectories = true IME.dlgOpenPath.canChooseFiles = false
IME.dlgOpenPath.canChooseDirectories = true
let bolPreviousFolderValidity = mgrLangModel.checkIfSpecifiedUserDataFolderValid( let bolPreviousFolderValidity = mgrLangModel.checkIfSpecifiedUserDataFolderValid(
mgrPrefs.userDataFolderSpecified.expandingTildeInPath) mgrPrefs.userDataFolderSpecified.expandingTildeInPath)
if let window = ctlPrefUI.shared.controller.window { if let window = ctlPrefUI.shared.controller.window {
IME.dlgOpenPath.beginSheetModal(for: window) { result in IME.dlgOpenPath.beginSheetModal(for: window) { result in
if result == NSApplication.ModalResponse.OK { if result == NSApplication.ModalResponse.OK {
if IME.dlgOpenPath.url != nil { if IME.dlgOpenPath.url != nil {
// CommonDialog // CommonDialog
// //
var newPath = IME.dlgOpenPath.url!.path var newPath = IME.dlgOpenPath.url!.path
newPath.ensureTrailingSlash() newPath.ensureTrailingSlash()
if mgrLangModel.checkIfSpecifiedUserDataFolderValid(newPath) { if mgrLangModel.checkIfSpecifiedUserDataFolderValid(newPath) {
mgrPrefs.userDataFolderSpecified = newPath mgrPrefs.userDataFolderSpecified = newPath
tbxUserDataPathSpecified = mgrPrefs.userDataFolderSpecified tbxUserDataPathSpecified = mgrPrefs.userDataFolderSpecified
IME.initLangModels(userOnly: true) IME.initLangModels(userOnly: true)
(NSApplication.shared.delegate as! AppDelegate).updateStreamHelperPath() (NSApplication.shared.delegate as! AppDelegate).updateStreamHelperPath()
} else { } else {
clsSFX.beep() clsSFX.beep()
if !bolPreviousFolderValidity { if !bolPreviousFolderValidity {
mgrPrefs.resetSpecifiedUserDataFolder() mgrPrefs.resetSpecifiedUserDataFolder()
}
return
} }
return
} }
} else {
if !bolPreviousFolderValidity {
mgrPrefs.resetSpecifiedUserDataFolder()
}
return
} }
} else {
if !bolPreviousFolderValidity {
mgrPrefs.resetSpecifiedUserDataFolder()
}
return
} }
} }
} label: {
Text("...")
}
Button {
mgrPrefs.resetSpecifiedUserDataFolder()
tbxUserDataPathSpecified = ""
} label: {
Text("")
} }
} label: {
Text("...")
}
Button {
mgrPrefs.resetSpecifiedUserDataFolder()
tbxUserDataPathSpecified = ""
} label: {
Text("")
} }
Toggle(
LocalizedStringKey("Automatically reload user data files if changes detected"),
isOn: $selAutoReloadUserData.onChange {
mgrPrefs.shouldAutoReloadUserDataFiles = selAutoReloadUserData
}
).controlSize(.small)
Divider()
Toggle(
LocalizedStringKey("Enable CNS11643 Support (2022-07-20)"),
isOn: $selEnableCNS11643.onChange {
mgrPrefs.cns11643Enabled = selEnableCNS11643
mgrLangModel.setCNSEnabled(mgrPrefs.cns11643Enabled)
}
)
Toggle(
LocalizedStringKey("Enable symbol input support (incl. certain emoji symbols)"),
isOn: $selEnableSymbolInputSupport.onChange {
mgrPrefs.symbolInputEnabled = selEnableSymbolInputSupport
mgrLangModel.setSymbolEnabled(mgrPrefs.symbolInputEnabled)
}
)
Toggle(
LocalizedStringKey("Allow boosting / excluding a candidate of single kanji"),
isOn: $selAllowBoostingSingleKanjiAsUserPhrase.onChange {
mgrPrefs.allowBoostingSingleKanjiAsUserPhrase = selAllowBoostingSingleKanjiAsUserPhrase
}
)
Toggle(
LocalizedStringKey("Applying typing suggestions from half-life user override model"),
isOn: $selFetchSuggestionsFromUserOverrideModel.onChange {
mgrPrefs.fetchSuggestionsFromUserOverrideModel = selFetchSuggestionsFromUserOverrideModel
}
)
Toggle(
LocalizedStringKey("Always use fixed listing order in candidate window"),
isOn: $selUseFixecCandidateOrderOnSelection.onChange {
mgrPrefs.useFixecCandidateOrderOnSelection = selUseFixecCandidateOrderOnSelection
}
)
} }
Toggle(
LocalizedStringKey("Automatically reload user data files if changes detected"),
isOn: $selAutoReloadUserData.onChange {
mgrPrefs.shouldAutoReloadUserDataFiles = selAutoReloadUserData
}
).controlSize(.small)
Divider()
Toggle(
LocalizedStringKey("Enable CNS11643 Support (2022-07-20)"),
isOn: $selEnableCNS11643.onChange {
mgrPrefs.cns11643Enabled = selEnableCNS11643
mgrLangModel.setCNSEnabled(mgrPrefs.cns11643Enabled)
}
)
Toggle(
LocalizedStringKey("Enable symbol input support (incl. certain emoji symbols)"),
isOn: $selEnableSymbolInputSupport.onChange {
mgrPrefs.symbolInputEnabled = selEnableSymbolInputSupport
mgrLangModel.setSymbolEnabled(mgrPrefs.symbolInputEnabled)
}
)
Toggle(
LocalizedStringKey("Allow boosting / excluding a candidate of single kanji"),
isOn: $selAllowBoostingSingleKanjiAsUserPhrase.onChange {
mgrPrefs.allowBoostingSingleKanjiAsUserPhrase = selAllowBoostingSingleKanjiAsUserPhrase
}
)
Toggle(
LocalizedStringKey("Applying typing suggestions from half-life user override model"),
isOn: $selFetchSuggestionsFromUserOverrideModel.onChange {
mgrPrefs.fetchSuggestionsFromUserOverrideModel = selFetchSuggestionsFromUserOverrideModel
}
)
Toggle(
LocalizedStringKey("Always use fixed listing order in candidate window"),
isOn: $selUseFixecCandidateOrderOnSelection.onChange {
mgrPrefs.useFixecCandidateOrderOnSelection = selUseFixecCandidateOrderOnSelection
}
)
} }
} }.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true)
} }
} }

View File

@ -38,6 +38,8 @@ struct suiPrefPaneExperience: View {
forKey: UserDef.kUpperCaseLetterKeyBehavior.rawValue) forKey: UserDef.kUpperCaseLetterKeyBehavior.rawValue)
@State private var selDisableShiftTogglingAlphanumericalMode: Bool = UserDefaults.standard.bool( @State private var selDisableShiftTogglingAlphanumericalMode: Bool = UserDefaults.standard.bool(
forKey: UserDef.kDisableShiftTogglingAlphanumericalMode.rawValue) forKey: UserDef.kDisableShiftTogglingAlphanumericalMode.rawValue)
private let contentMaxHeight: Double = 430
private let contentWidth: Double = { private let contentWidth: Double = {
switch mgrPrefs.appleLanguages[0] { switch mgrPrefs.appleLanguages[0] {
case "ja": case "ja":
@ -52,128 +54,130 @@ struct suiPrefPaneExperience: View {
}() }()
var body: some View { var body: some View {
Preferences.Container(contentWidth: contentWidth) { ScrollView {
Preferences.Section(label: { Text(LocalizedStringKey("Cursor Selection:")) }) { Preferences.Container(contentWidth: contentWidth) {
Picker( Preferences.Section(label: { Text(LocalizedStringKey("Cursor Selection:")) }) {
"", Picker(
selection: $selCursorPosition.onChange { "",
mgrPrefs.useRearCursorMode = (selCursorPosition == 1) ? true : false selection: $selCursorPosition.onChange {
mgrPrefs.useRearCursorMode = (selCursorPosition == 1) ? true : false
}
) {
Text(LocalizedStringKey("in front of the phrase (like macOS built-in Zhuyin IME)")).tag(0)
Text(LocalizedStringKey("at the rear of the phrase (like Microsoft New Phonetic)")).tag(1)
} }
) { .labelsHidden()
Text(LocalizedStringKey("in front of the phrase (like macOS built-in Zhuyin IME)")).tag(0) .pickerStyle(RadioGroupPickerStyle())
Text(LocalizedStringKey("at the rear of the phrase (like Microsoft New Phonetic)")).tag(1) Text(LocalizedStringKey("Choose the cursor position where you want to list possible candidates."))
.preferenceDescription()
Toggle(
LocalizedStringKey("Push the cursor in front of the phrase after selection"),
isOn: $selPushCursorAfterSelection.onChange {
mgrPrefs.moveCursorAfterSelectingCandidate = selPushCursorAfterSelection
}
).controlSize(.small)
} }
.labelsHidden() Preferences.Section(title: "(Shift+)Tab:") {
.pickerStyle(RadioGroupPickerStyle()) Picker(
Text(LocalizedStringKey("Choose the cursor position where you want to list possible candidates.")) "",
.preferenceDescription() selection: $selKeyBehaviorShiftTab.onChange {
Toggle( mgrPrefs.specifyShiftTabKeyBehavior = (selKeyBehaviorShiftTab == 1) ? true : false
LocalizedStringKey("Push the cursor in front of the phrase after selection"), }
isOn: $selPushCursorAfterSelection.onChange { ) {
mgrPrefs.moveCursorAfterSelectingCandidate = selPushCursorAfterSelection Text(LocalizedStringKey("for cycling candidates")).tag(0)
Text(LocalizedStringKey("for cycling pages")).tag(1)
} }
).controlSize(.small) .labelsHidden()
} .horizontalRadioGroupLayout()
Preferences.Section(title: "(Shift+)Tab:") { .pickerStyle(RadioGroupPickerStyle())
Picker( Text(LocalizedStringKey("Choose the behavior of (Shift+)Tab key in the candidate window."))
"", .preferenceDescription()
selection: $selKeyBehaviorShiftTab.onChange {
mgrPrefs.specifyShiftTabKeyBehavior = (selKeyBehaviorShiftTab == 1) ? true : false
}
) {
Text(LocalizedStringKey("for cycling candidates")).tag(0)
Text(LocalizedStringKey("for cycling pages")).tag(1)
} }
.labelsHidden() Preferences.Section(label: { Text(LocalizedStringKey("(Shift+)Space:")) }) {
.horizontalRadioGroupLayout() Picker(
.pickerStyle(RadioGroupPickerStyle()) "",
Text(LocalizedStringKey("Choose the behavior of (Shift+)Tab key in the candidate window.")) selection: $selKeyBehaviorShiftSpace.onChange {
.preferenceDescription() mgrPrefs.specifyShiftSpaceKeyBehavior = (selKeyBehaviorShiftSpace == 1) ? true : false
} }
Preferences.Section(label: { Text(LocalizedStringKey("(Shift+)Space:")) }) { ) {
Picker( Text(LocalizedStringKey("Space to +cycle candidates, Shift+Space to +cycle pages")).tag(0)
"", Text(LocalizedStringKey("Space to +cycle pages, Shift+Space to +cycle candidates")).tag(1)
selection: $selKeyBehaviorShiftSpace.onChange {
mgrPrefs.specifyShiftSpaceKeyBehavior = (selKeyBehaviorShiftSpace == 1) ? true : false
} }
) { .labelsHidden()
Text(LocalizedStringKey("Space to +cycle candidates, Shift+Space to +cycle pages")).tag(0) .pickerStyle(RadioGroupPickerStyle())
Text(LocalizedStringKey("Space to +cycle pages, Shift+Space to +cycle candidates")).tag(1) Text(LocalizedStringKey("Choose the behavior of (Shift+)Space key with candidates."))
.preferenceDescription()
} }
.labelsHidden() Preferences.Section(label: { Text(LocalizedStringKey("Shift+Letter:")) }) {
.pickerStyle(RadioGroupPickerStyle()) Picker(
Text(LocalizedStringKey("Choose the behavior of (Shift+)Space key with candidates.")) "",
.preferenceDescription() selection: $selUpperCaseLetterKeyBehavior.onChange {
} mgrPrefs.upperCaseLetterKeyBehavior = selUpperCaseLetterKeyBehavior
Preferences.Section(label: { Text(LocalizedStringKey("Shift+Letter:")) }) { }
Picker( ) {
"", Text(LocalizedStringKey("Type them into inline composition buffer")).tag(0)
selection: $selUpperCaseLetterKeyBehavior.onChange { Text(LocalizedStringKey("Directly commit lowercased letters")).tag(1)
mgrPrefs.upperCaseLetterKeyBehavior = selUpperCaseLetterKeyBehavior Text(LocalizedStringKey("Directly commit uppercased letters")).tag(2)
} }
) { .labelsHidden()
Text(LocalizedStringKey("Type them into inline composition buffer")).tag(0) .pickerStyle(RadioGroupPickerStyle())
Text(LocalizedStringKey("Directly commit lowercased letters")).tag(1) Text(LocalizedStringKey("Choose the behavior of Shift+Letter key with letter inputs."))
Text(LocalizedStringKey("Directly commit uppercased letters")).tag(2) .preferenceDescription()
}
Preferences.Section(label: { Text(LocalizedStringKey("Misc Settings:")) }) {
Toggle(
LocalizedStringKey("Enable Space key for calling candidate window"),
isOn: $selKeyBehaviorSpaceForCallingCandidate.onChange {
mgrPrefs.chooseCandidateUsingSpace = selKeyBehaviorSpaceForCallingCandidate
}
)
Toggle(
LocalizedStringKey("Use ESC key to clear the entire input buffer"),
isOn: $selKeyBehaviorESCForClearingTheBuffer.onChange {
mgrPrefs.escToCleanInputBuffer = selKeyBehaviorESCForClearingTheBuffer
}
)
Toggle(
LocalizedStringKey("Automatically correct reading combinations when typing"),
isOn: $selAutoCorrectReadingCombination.onChange {
mgrPrefs.autoCorrectReadingCombination = selAutoCorrectReadingCombination
}
)
Toggle(
LocalizedStringKey("Allow using Enter key to confirm associated candidate selection"),
isOn: $selAlsoConfirmAssociatedCandidatesByEnter.onChange {
mgrPrefs.alsoConfirmAssociatedCandidatesByEnter = selAlsoConfirmAssociatedCandidatesByEnter
}
)
Toggle(
LocalizedStringKey("Also toggle alphanumerical mode with Left-Shift"),
isOn: $selTogglingAlphanumericalModeWithLShift.onChange {
mgrPrefs.togglingAlphanumericalModeWithLShift = selTogglingAlphanumericalModeWithLShift
}
).disabled(mgrPrefs.disableShiftTogglingAlphanumericalMode == true)
Toggle(
LocalizedStringKey("Completely disable using Shift key to toggling alphanumerical mode"),
isOn: $selDisableShiftTogglingAlphanumericalMode.onChange {
mgrPrefs.disableShiftTogglingAlphanumericalMode = selDisableShiftTogglingAlphanumericalMode
}
)
Toggle(
LocalizedStringKey("Allow backspace-editing miscomposed readings"),
isOn: $selKeepReadingUponCompositionError.onChange {
mgrPrefs.keepReadingUponCompositionError = selKeepReadingUponCompositionError
}
)
Toggle(
LocalizedStringKey("Emulating select-candidate-per-character mode"),
isOn: $selEnableSCPCTypingMode.onChange {
mgrPrefs.useSCPCTypingMode = selEnableSCPCTypingMode
}
)
Text(LocalizedStringKey("An accommodation for elder computer users."))
.preferenceDescription()
} }
.labelsHidden()
.pickerStyle(RadioGroupPickerStyle())
Text(LocalizedStringKey("Choose the behavior of Shift+Letter key with letter inputs."))
.preferenceDescription()
} }
Preferences.Section(label: { Text(LocalizedStringKey("Misc Settings:")) }) { }.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true)
Toggle(
LocalizedStringKey("Enable Space key for calling candidate window"),
isOn: $selKeyBehaviorSpaceForCallingCandidate.onChange {
mgrPrefs.chooseCandidateUsingSpace = selKeyBehaviorSpaceForCallingCandidate
}
)
Toggle(
LocalizedStringKey("Use ESC key to clear the entire input buffer"),
isOn: $selKeyBehaviorESCForClearingTheBuffer.onChange {
mgrPrefs.escToCleanInputBuffer = selKeyBehaviorESCForClearingTheBuffer
}
)
Toggle(
LocalizedStringKey("Automatically correct reading combinations when typing"),
isOn: $selAutoCorrectReadingCombination.onChange {
mgrPrefs.autoCorrectReadingCombination = selAutoCorrectReadingCombination
}
)
Toggle(
LocalizedStringKey("Allow using Enter key to confirm associated candidate selection"),
isOn: $selAlsoConfirmAssociatedCandidatesByEnter.onChange {
mgrPrefs.alsoConfirmAssociatedCandidatesByEnter = selAlsoConfirmAssociatedCandidatesByEnter
}
)
Toggle(
LocalizedStringKey("Also toggle alphanumerical mode with Left-Shift"),
isOn: $selTogglingAlphanumericalModeWithLShift.onChange {
mgrPrefs.togglingAlphanumericalModeWithLShift = selTogglingAlphanumericalModeWithLShift
}
).disabled(mgrPrefs.disableShiftTogglingAlphanumericalMode == true)
Toggle(
LocalizedStringKey("Completely disable using Shift key to toggling alphanumerical mode"),
isOn: $selDisableShiftTogglingAlphanumericalMode.onChange {
mgrPrefs.disableShiftTogglingAlphanumericalMode = selDisableShiftTogglingAlphanumericalMode
}
)
Toggle(
LocalizedStringKey("Allow backspace-editing miscomposed readings"),
isOn: $selKeepReadingUponCompositionError.onChange {
mgrPrefs.keepReadingUponCompositionError = selKeepReadingUponCompositionError
}
)
Toggle(
LocalizedStringKey("Emulating select-candidate-per-character mode"),
isOn: $selEnableSCPCTypingMode.onChange {
mgrPrefs.useSCPCTypingMode = selEnableSCPCTypingMode
}
)
Text(LocalizedStringKey("An accommodation for elder computer users."))
.preferenceDescription()
}
}
} }
} }

View File

@ -37,6 +37,8 @@ struct suiPrefPaneGeneral: View {
@State private var selEnableAutoUpdateCheck = UserDefaults.standard.bool( @State private var selEnableAutoUpdateCheck = UserDefaults.standard.bool(
forKey: UserDef.kCheckUpdateAutomatically.rawValue) forKey: UserDef.kCheckUpdateAutomatically.rawValue)
@State private var selEnableDebugMode = UserDefaults.standard.bool(forKey: UserDef.kIsDebugModeEnabled.rawValue) @State private var selEnableDebugMode = UserDefaults.standard.bool(forKey: UserDef.kIsDebugModeEnabled.rawValue)
private let contentMaxHeight: Double = 430
private let contentWidth: Double = { private let contentWidth: Double = {
switch mgrPrefs.appleLanguages[0] { switch mgrPrefs.appleLanguages[0] {
case "ja": case "ja":
@ -51,135 +53,137 @@ struct suiPrefPaneGeneral: View {
}() }()
var body: some View { var body: some View {
Preferences.Container(contentWidth: contentWidth) { ScrollView {
Preferences.Section(bottomDivider: false, label: { Text(LocalizedStringKey("Candidate Size:")) }) { Preferences.Container(contentWidth: contentWidth) {
Picker( Preferences.Section(bottomDivider: false, label: { Text(LocalizedStringKey("Candidate Size:")) }) {
"", Picker(
selection: $selCandidateUIFontSize.onChange { "",
mgrPrefs.candidateListTextSize = CGFloat(selCandidateUIFontSize) selection: $selCandidateUIFontSize.onChange {
} mgrPrefs.candidateListTextSize = CGFloat(selCandidateUIFontSize)
) {
Text("12").tag(12)
Text("14").tag(14)
Text("16").tag(16)
Text("18").tag(18)
Text("24").tag(24)
Text("32").tag(32)
Text("64").tag(64)
Text("96").tag(96)
}
.labelsHidden()
.frame(width: 120.0)
Text(LocalizedStringKey("Choose candidate font size for better visual clarity."))
.preferenceDescription()
}
Preferences.Section(bottomDivider: false, label: { Text(LocalizedStringKey("UI Language:")) }) {
Picker(
LocalizedStringKey("Follow OS settings"),
selection: $selUILanguage.onChange {
IME.prtDebugIntel(selUILanguage[0])
if selUILanguage == mgrPrefs.appleLanguages
|| (selUILanguage[0] == "auto"
&& UserDefaults.standard.object(forKey: UserDef.kAppleLanguages.rawValue) == nil)
{
return
} }
if selUILanguage[0] != "auto" { ) {
mgrPrefs.appleLanguages = selUILanguage Text("12").tag(12)
} else { Text("14").tag(14)
UserDefaults.standard.removeObject(forKey: UserDef.kAppleLanguages.rawValue) Text("16").tag(16)
} Text("18").tag(18)
NSLog("vChewing App self-terminated due to UI language change.") Text("24").tag(24)
NSApplication.shared.terminate(nil) Text("32").tag(32)
Text("64").tag(64)
Text("96").tag(96)
} }
) { .labelsHidden()
Text(LocalizedStringKey("Follow OS settings")).tag(["auto"]) .frame(width: 120.0)
Text(LocalizedStringKey("Simplified Chinese")).tag(["zh-Hans"]) Text(LocalizedStringKey("Choose candidate font size for better visual clarity."))
Text(LocalizedStringKey("Traditional Chinese")).tag(["zh-Hant"]) .preferenceDescription()
Text(LocalizedStringKey("Japanese")).tag(["ja"])
Text(LocalizedStringKey("English")).tag(["en"])
} }
.labelsHidden() Preferences.Section(bottomDivider: false, label: { Text(LocalizedStringKey("UI Language:")) }) {
.frame(width: 180.0) Picker(
LocalizedStringKey("Follow OS settings"),
selection: $selUILanguage.onChange {
IME.prtDebugIntel(selUILanguage[0])
if selUILanguage == mgrPrefs.appleLanguages
|| (selUILanguage[0] == "auto"
&& UserDefaults.standard.object(forKey: UserDef.kAppleLanguages.rawValue) == nil)
{
return
}
if selUILanguage[0] != "auto" {
mgrPrefs.appleLanguages = selUILanguage
} else {
UserDefaults.standard.removeObject(forKey: UserDef.kAppleLanguages.rawValue)
}
NSLog("vChewing App self-terminated due to UI language change.")
NSApplication.shared.terminate(nil)
}
) {
Text(LocalizedStringKey("Follow OS settings")).tag(["auto"])
Text(LocalizedStringKey("Simplified Chinese")).tag(["zh-Hans"])
Text(LocalizedStringKey("Traditional Chinese")).tag(["zh-Hant"])
Text(LocalizedStringKey("Japanese")).tag(["ja"])
Text(LocalizedStringKey("English")).tag(["en"])
}
.labelsHidden()
.frame(width: 180.0)
Text(LocalizedStringKey("Change user interface language (will reboot the IME).")) Text(LocalizedStringKey("Change user interface language (will reboot the IME)."))
.preferenceDescription() .preferenceDescription()
}
Preferences.Section(bottomDivider: true, label: { Text(LocalizedStringKey("Candidate Layout:")) }) {
Picker(
"",
selection: $selEnableHorizontalCandidateLayout.onChange {
mgrPrefs.useHorizontalCandidateList = selEnableHorizontalCandidateLayout
}
) {
Text(LocalizedStringKey("Vertical")).tag(false)
Text(LocalizedStringKey("Horizontal")).tag(true)
} }
.labelsHidden() Preferences.Section(bottomDivider: true, label: { Text(LocalizedStringKey("Candidate Layout:")) }) {
.horizontalRadioGroupLayout() Picker(
.pickerStyle(RadioGroupPickerStyle()) "",
Text(LocalizedStringKey("Choose your preferred layout of the candidate window.")) selection: $selEnableHorizontalCandidateLayout.onChange {
.preferenceDescription() mgrPrefs.useHorizontalCandidateList = selEnableHorizontalCandidateLayout
Toggle( }
LocalizedStringKey("Show page buttons in candidate window"), ) {
isOn: $selShowPageButtonsInCandidateUI.onChange { Text(LocalizedStringKey("Vertical")).tag(false)
mgrPrefs.showPageButtonsInCandidateWindow = selShowPageButtonsInCandidateUI Text(LocalizedStringKey("Horizontal")).tag(true)
} }
) .labelsHidden()
.controlSize(.small) .horizontalRadioGroupLayout()
.pickerStyle(RadioGroupPickerStyle())
Text(LocalizedStringKey("Choose your preferred layout of the candidate window."))
.preferenceDescription()
Toggle(
LocalizedStringKey("Show page buttons in candidate window"),
isOn: $selShowPageButtonsInCandidateUI.onChange {
mgrPrefs.showPageButtonsInCandidateWindow = selShowPageButtonsInCandidateUI
}
)
.controlSize(.small)
}
Preferences.Section(bottomDivider: true, label: { Text(LocalizedStringKey("Output Settings:")) }) {
Toggle(
LocalizedStringKey("Auto-convert traditional Chinese glyphs to KangXi characters"),
isOn: $selEnableKanjiConvToKangXi.onChange {
mgrPrefs.chineseConversionEnabled = selEnableKanjiConvToKangXi
selEnableKanjiConvToJIS = mgrPrefs.shiftJISShinjitaiOutputEnabled
}
)
Toggle(
LocalizedStringKey("Auto-convert traditional Chinese glyphs to JIS Shinjitai characters"),
isOn: $selEnableKanjiConvToJIS.onChange {
mgrPrefs.shiftJISShinjitaiOutputEnabled = selEnableKanjiConvToJIS
selEnableKanjiConvToKangXi = mgrPrefs.chineseConversionEnabled
}
)
Toggle(
LocalizedStringKey("Show Hanyu-Pinyin in the inline composition buffer & tooltip"),
isOn: $selShowHanyuPinyinInCompositionBuffer.onChange {
mgrPrefs.showHanyuPinyinInCompositionBuffer = selShowHanyuPinyinInCompositionBuffer
}
)
Toggle(
LocalizedStringKey("Commit Hanyu-Pinyin instead on Ctrl(+Option)+Command+Enter"),
isOn: $selInlineDumpPinyinInLieuOfZhuyin.onChange {
mgrPrefs.inlineDumpPinyinInLieuOfZhuyin = selInlineDumpPinyinInLieuOfZhuyin
}
)
Toggle(
LocalizedStringKey("Stop farting (when typed phonetic combination is invalid, etc.)"),
isOn: $selEnableFartSuppressor.onChange {
mgrPrefs.shouldNotFartInLieuOfBeep = selEnableFartSuppressor
clsSFX.beep()
}
)
}
Preferences.Section(label: { Text(LocalizedStringKey("Misc Settings:")).controlSize(.small) }) {
Toggle(
LocalizedStringKey("Check for updates automatically"),
isOn: $selEnableAutoUpdateCheck.onChange {
mgrPrefs.checkUpdateAutomatically = selEnableAutoUpdateCheck
}
)
.controlSize(.small)
Toggle(
LocalizedStringKey("Debug Mode"),
isOn: $selEnableDebugMode.onChange {
mgrPrefs.isDebugModeEnabled = selEnableDebugMode
}
)
.controlSize(.small)
}
} }
Preferences.Section(bottomDivider: true, label: { Text(LocalizedStringKey("Output Settings:")) }) { }.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true)
Toggle(
LocalizedStringKey("Auto-convert traditional Chinese glyphs to KangXi characters"),
isOn: $selEnableKanjiConvToKangXi.onChange {
mgrPrefs.chineseConversionEnabled = selEnableKanjiConvToKangXi
selEnableKanjiConvToJIS = mgrPrefs.shiftJISShinjitaiOutputEnabled
}
)
Toggle(
LocalizedStringKey("Auto-convert traditional Chinese glyphs to JIS Shinjitai characters"),
isOn: $selEnableKanjiConvToJIS.onChange {
mgrPrefs.shiftJISShinjitaiOutputEnabled = selEnableKanjiConvToJIS
selEnableKanjiConvToKangXi = mgrPrefs.chineseConversionEnabled
}
)
Toggle(
LocalizedStringKey("Show Hanyu-Pinyin in the inline composition buffer & tooltip"),
isOn: $selShowHanyuPinyinInCompositionBuffer.onChange {
mgrPrefs.showHanyuPinyinInCompositionBuffer = selShowHanyuPinyinInCompositionBuffer
}
)
Toggle(
LocalizedStringKey("Commit Hanyu-Pinyin instead on Ctrl(+Option)+Command+Enter"),
isOn: $selInlineDumpPinyinInLieuOfZhuyin.onChange {
mgrPrefs.inlineDumpPinyinInLieuOfZhuyin = selInlineDumpPinyinInLieuOfZhuyin
}
)
Toggle(
LocalizedStringKey("Stop farting (when typed phonetic combination is invalid, etc.)"),
isOn: $selEnableFartSuppressor.onChange {
mgrPrefs.shouldNotFartInLieuOfBeep = selEnableFartSuppressor
clsSFX.beep()
}
)
}
Preferences.Section(label: { Text(LocalizedStringKey("Misc Settings:")).controlSize(.small) }) {
Toggle(
LocalizedStringKey("Check for updates automatically"),
isOn: $selEnableAutoUpdateCheck.onChange {
mgrPrefs.checkUpdateAutomatically = selEnableAutoUpdateCheck
}
)
.controlSize(.small)
Toggle(
LocalizedStringKey("Debug Mode"),
isOn: $selEnableDebugMode.onChange {
mgrPrefs.isDebugModeEnabled = selEnableDebugMode
}
)
.controlSize(.small)
}
}
} }
} }

View File

@ -28,6 +28,7 @@ struct suiPrefPaneKeyboard: View {
@State private var selUsingHotKeyCurrencyNumerals = UserDefaults.standard.bool( @State private var selUsingHotKeyCurrencyNumerals = UserDefaults.standard.bool(
forKey: UserDef.kUsingHotKeyCurrencyNumerals.rawValue) forKey: UserDef.kUsingHotKeyCurrencyNumerals.rawValue)
private let contentMaxHeight: Double = 430
private let contentWidth: Double = { private let contentWidth: Double = {
switch mgrPrefs.appleLanguages[0] { switch mgrPrefs.appleLanguages[0] {
case "ja": case "ja":
@ -42,192 +43,194 @@ struct suiPrefPaneKeyboard: View {
}() }()
var body: some View { var body: some View {
Preferences.Container(contentWidth: contentWidth) { ScrollView {
Preferences.Section(label: { Text(LocalizedStringKey("Selection Keys:")) }) { Preferences.Container(contentWidth: contentWidth) {
ComboBox( Preferences.Section(label: { Text(LocalizedStringKey("Selection Keys:")) }) {
items: mgrPrefs.suggestedCandidateKeys, ComboBox(
text: $selSelectionKeys.onChange { items: mgrPrefs.suggestedCandidateKeys,
let value = selSelectionKeys text: $selSelectionKeys.onChange {
let keys: String = value.trimmingCharacters(in: .whitespacesAndNewlines).deduplicate let value = selSelectionKeys
do { let keys: String = value.trimmingCharacters(in: .whitespacesAndNewlines).deduplicate
try mgrPrefs.validate(candidateKeys: keys) do {
mgrPrefs.candidateKeys = keys try mgrPrefs.validate(candidateKeys: keys)
selSelectionKeys = mgrPrefs.candidateKeys mgrPrefs.candidateKeys = keys
} catch mgrPrefs.CandidateKeyError.empty { selSelectionKeys = mgrPrefs.candidateKeys
selSelectionKeys = mgrPrefs.candidateKeys } catch mgrPrefs.CandidateKeyError.empty {
} catch { selSelectionKeys = mgrPrefs.candidateKeys
if let window = ctlPrefUI.shared.controller.window { } catch {
let alert = NSAlert(error: error) if let window = ctlPrefUI.shared.controller.window {
alert.beginSheetModal(for: window) { _ in let alert = NSAlert(error: error)
selSelectionKeys = mgrPrefs.candidateKeys alert.beginSheetModal(for: window) { _ in
selSelectionKeys = mgrPrefs.candidateKeys
}
clsSFX.beep()
} }
clsSFX.beep()
} }
} }
} ).frame(width: 180)
).frame(width: 180)
Text(
LocalizedStringKey(
"Choose or hit Enter to confim your prefered keys for selecting candidates."
)
)
.preferenceDescription()
}
Preferences.Section(label: { Text(LocalizedStringKey("Phonetic Parser:")) }) {
HStack {
Picker(
"",
selection: $selMandarinParser.onChange {
let value = selMandarinParser
mgrPrefs.mandarinParser = value
switch value {
case 0:
if !AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(mgrPrefs.basicKeyboardLayout) {
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ZhuyinBopomofo"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
}
default:
if AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(mgrPrefs.basicKeyboardLayout) {
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ABC"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
}
}
}
) {
Group {
Text(LocalizedStringKey("Dachen (Microsoft Standard / Wang / 01, etc.)")).tag(0)
Text(LocalizedStringKey("Eten Traditional")).tag(1)
Text(LocalizedStringKey("IBM")).tag(4)
Text(LocalizedStringKey("MiTAC")).tag(5)
Text(LocalizedStringKey("Seigyou")).tag(8)
Text(LocalizedStringKey("Fake Seigyou")).tag(6)
}
Divider()
Group {
Text(LocalizedStringKey("Dachen 26 (libChewing)")).tag(7)
Text(LocalizedStringKey("Eten 26")).tag(3)
Text(LocalizedStringKey("Hsu")).tag(2)
Text(LocalizedStringKey("Starlight")).tag(9)
}
Divider()
Group {
Text(LocalizedStringKey("Hanyu Pinyin with Numeral Intonation")).tag(10)
Text(LocalizedStringKey("Secondary Pinyin with Numeral Intonation")).tag(11)
Text(LocalizedStringKey("Yale Pinyin with Numeral Intonation")).tag(12)
Text(LocalizedStringKey("Hualuo Pinyin with Numeral Intonation")).tag(13)
Text(LocalizedStringKey("Universal Pinyin with Numeral Intonation")).tag(14)
}
}
.labelsHidden()
Button {
mgrPrefs.mandarinParser = 0
selMandarinParser = mgrPrefs.mandarinParser
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ZhuyinBopomofo"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
} label: {
Text("↻ㄅ")
}
Button {
mgrPrefs.mandarinParser = 10
selMandarinParser = mgrPrefs.mandarinParser
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ABC"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
} label: {
Text("↻A")
}
}
.frame(width: 380.0)
Text(LocalizedStringKey("Choose the phonetic layout for Mandarin parser."))
.preferenceDescription()
}
Preferences.Section(bottomDivider: true, label: { Text(LocalizedStringKey("Basic Keyboard Layout:")) }) {
HStack {
Picker(
"",
selection: $selBasicKeyboardLayout.onChange {
let value = selBasicKeyboardLayout
mgrPrefs.basicKeyboardLayout = value
if AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(value) {
mgrPrefs.mandarinParser = 0
selMandarinParser = mgrPrefs.mandarinParser
}
}
) {
ForEach(0...(IME.arrEnumerateSystemKeyboardLayouts.count - 1), id: \.self) { id in
Text(IME.arrEnumerateSystemKeyboardLayouts[id].strName).tag(
IME.arrEnumerateSystemKeyboardLayouts[id].strValue)
}.id(UUID())
}
.labelsHidden()
.frame(width: 240.0)
}
Text(LocalizedStringKey("Choose the macOS-level basic keyboard layout."))
.preferenceDescription()
}
Preferences.Section(bottomDivider: true, label: { Text(LocalizedStringKey("Keyboard Shortcuts:")) }) {
Toggle(
LocalizedStringKey("Per-Char Select Mode"),
isOn: $selUsingHotKeySCPC.onChange {
mgrPrefs.usingHotKeySCPC = selUsingHotKeySCPC
}
)
Toggle(
LocalizedStringKey("Per-Char Associated Phrases"),
isOn: $selUsingHotKeyAssociates.onChange {
mgrPrefs.usingHotKeyAssociates = selUsingHotKeyAssociates
}
)
Toggle(
LocalizedStringKey("CNS11643 Mode"),
isOn: $selUsingHotKeyCNS.onChange {
mgrPrefs.usingHotKeyCNS = selUsingHotKeyCNS
}
)
Toggle(
LocalizedStringKey("Force KangXi Writing"),
isOn: $selUsingHotKeyKangXi.onChange {
mgrPrefs.usingHotKeyKangXi = selUsingHotKeyKangXi
}
)
Toggle(
LocalizedStringKey("JIS Shinjitai Output"),
isOn: $selUsingHotKeyJIS.onChange {
mgrPrefs.usingHotKeyJIS = selUsingHotKeyJIS
}
)
Toggle(
LocalizedStringKey("Half-Width Punctuation Mode"),
isOn: $selUsingHotKeyHalfWidthASCII.onChange {
mgrPrefs.usingHotKeyHalfWidthASCII = selUsingHotKeyHalfWidthASCII
}
)
Toggle(
LocalizedStringKey("Currency Numeral Output"),
isOn: $selUsingHotKeyCurrencyNumerals.onChange {
mgrPrefs.usingHotKeyCurrencyNumerals = selUsingHotKeyCurrencyNumerals
}
)
}
}
Divider()
Preferences.Container(contentWidth: contentWidth) {
Preferences.Section(title: "") {
VStack(alignment: .leading, spacing: 10) {
Text( Text(
LocalizedStringKey( LocalizedStringKey(
"Non-QWERTY alphanumerical keyboard layouts are for Hanyu Pinyin parser only." "Choose or hit Enter to confim your prefered keys for selecting candidates."
)
)
.preferenceDescription()
Text(
LocalizedStringKey(
"Apple Dynamic Bopomofo Basic Keyboard Layouts (Dachen & Eten Traditional) must match the Dachen parser in order to be functional."
) )
) )
.preferenceDescription() .preferenceDescription()
} }
Preferences.Section(label: { Text(LocalizedStringKey("Phonetic Parser:")) }) {
HStack {
Picker(
"",
selection: $selMandarinParser.onChange {
let value = selMandarinParser
mgrPrefs.mandarinParser = value
switch value {
case 0:
if !AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(mgrPrefs.basicKeyboardLayout) {
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ZhuyinBopomofo"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
}
default:
if AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(mgrPrefs.basicKeyboardLayout) {
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ABC"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
}
}
}
) {
Group {
Text(LocalizedStringKey("Dachen (Microsoft Standard / Wang / 01, etc.)")).tag(0)
Text(LocalizedStringKey("Eten Traditional")).tag(1)
Text(LocalizedStringKey("IBM")).tag(4)
Text(LocalizedStringKey("MiTAC")).tag(5)
Text(LocalizedStringKey("Seigyou")).tag(8)
Text(LocalizedStringKey("Fake Seigyou")).tag(6)
}
Divider()
Group {
Text(LocalizedStringKey("Dachen 26 (libChewing)")).tag(7)
Text(LocalizedStringKey("Eten 26")).tag(3)
Text(LocalizedStringKey("Hsu")).tag(2)
Text(LocalizedStringKey("Starlight")).tag(9)
}
Divider()
Group {
Text(LocalizedStringKey("Hanyu Pinyin with Numeral Intonation")).tag(10)
Text(LocalizedStringKey("Secondary Pinyin with Numeral Intonation")).tag(11)
Text(LocalizedStringKey("Yale Pinyin with Numeral Intonation")).tag(12)
Text(LocalizedStringKey("Hualuo Pinyin with Numeral Intonation")).tag(13)
Text(LocalizedStringKey("Universal Pinyin with Numeral Intonation")).tag(14)
}
}
.labelsHidden()
Button {
mgrPrefs.mandarinParser = 0
selMandarinParser = mgrPrefs.mandarinParser
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ZhuyinBopomofo"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
} label: {
Text("↻ㄅ")
}
Button {
mgrPrefs.mandarinParser = 10
selMandarinParser = mgrPrefs.mandarinParser
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ABC"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
} label: {
Text("↻A")
}
}
.frame(width: 380.0)
Text(LocalizedStringKey("Choose the phonetic layout for Mandarin parser."))
.preferenceDescription()
}
Preferences.Section(bottomDivider: true, label: { Text(LocalizedStringKey("Basic Keyboard Layout:")) }) {
HStack {
Picker(
"",
selection: $selBasicKeyboardLayout.onChange {
let value = selBasicKeyboardLayout
mgrPrefs.basicKeyboardLayout = value
if AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(value) {
mgrPrefs.mandarinParser = 0
selMandarinParser = mgrPrefs.mandarinParser
}
}
) {
ForEach(0...(IME.arrEnumerateSystemKeyboardLayouts.count - 1), id: \.self) { id in
Text(IME.arrEnumerateSystemKeyboardLayouts[id].strName).tag(
IME.arrEnumerateSystemKeyboardLayouts[id].strValue)
}.id(UUID())
}
.labelsHidden()
.frame(width: 240.0)
}
Text(LocalizedStringKey("Choose the macOS-level basic keyboard layout."))
.preferenceDescription()
}
Preferences.Section(bottomDivider: true, label: { Text(LocalizedStringKey("Keyboard Shortcuts:")) }) {
Toggle(
LocalizedStringKey("Per-Char Select Mode"),
isOn: $selUsingHotKeySCPC.onChange {
mgrPrefs.usingHotKeySCPC = selUsingHotKeySCPC
}
)
Toggle(
LocalizedStringKey("Per-Char Associated Phrases"),
isOn: $selUsingHotKeyAssociates.onChange {
mgrPrefs.usingHotKeyAssociates = selUsingHotKeyAssociates
}
)
Toggle(
LocalizedStringKey("CNS11643 Mode"),
isOn: $selUsingHotKeyCNS.onChange {
mgrPrefs.usingHotKeyCNS = selUsingHotKeyCNS
}
)
Toggle(
LocalizedStringKey("Force KangXi Writing"),
isOn: $selUsingHotKeyKangXi.onChange {
mgrPrefs.usingHotKeyKangXi = selUsingHotKeyKangXi
}
)
Toggle(
LocalizedStringKey("JIS Shinjitai Output"),
isOn: $selUsingHotKeyJIS.onChange {
mgrPrefs.usingHotKeyJIS = selUsingHotKeyJIS
}
)
Toggle(
LocalizedStringKey("Half-Width Punctuation Mode"),
isOn: $selUsingHotKeyHalfWidthASCII.onChange {
mgrPrefs.usingHotKeyHalfWidthASCII = selUsingHotKeyHalfWidthASCII
}
)
Toggle(
LocalizedStringKey("Currency Numeral Output"),
isOn: $selUsingHotKeyCurrencyNumerals.onChange {
mgrPrefs.usingHotKeyCurrencyNumerals = selUsingHotKeyCurrencyNumerals
}
)
}
} }
} Divider()
Preferences.Container(contentWidth: contentWidth) {
Preferences.Section(title: "") {
VStack(alignment: .leading, spacing: 10) {
Text(
LocalizedStringKey(
"Non-QWERTY alphanumerical keyboard layouts are for Hanyu Pinyin parser only."
)
)
.preferenceDescription()
Text(
LocalizedStringKey(
"Apple Dynamic Bopomofo Basic Keyboard Layouts (Dachen & Eten Traditional) must match the Dachen parser in order to be functional."
)
)
.preferenceDescription()
}
}
}
}.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true)
} }
} }