Merge pull request #38 from ShikiSuen/dev/Taiyan-Extension
Keyboard // Refactored Taiyan Engine + Choice for Apple Zhuyin Bopomofo Layout.
This commit is contained in:
commit
01ab027d03
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -33,7 +33,6 @@ private let kShouldNotFartInLieuOfBeep = "ShouldNotFartInLieuOfBeep"
|
|||
private let kCandidateTextFontName = "CandidateTextFontName"
|
||||
private let kCandidateKeyLabelFontName = "CandidateKeyLabelFontName"
|
||||
private let kCandidateKeys = "CandidateKeys"
|
||||
private let kChineseConversionEngine = "ChineseConversionEngine"
|
||||
private let kPhraseReplacementEnabled = "PhraseReplacementEnabled"
|
||||
|
||||
private let kDefaultCandidateListTextSize: CGFloat = 18
|
||||
|
@ -154,20 +153,6 @@ struct ComposingBufferSize {
|
|||
}
|
||||
}
|
||||
|
||||
@objc enum ChineseConversionEngine: Int {
|
||||
case openCC
|
||||
case vxHanConvert
|
||||
|
||||
var name: String {
|
||||
switch (self) {
|
||||
case .openCC:
|
||||
return "OpenCC"
|
||||
case .vxHanConvert:
|
||||
return "VXHanConvert"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
@objc public class Preferences: NSObject {
|
||||
static func reset() {
|
||||
|
@ -193,7 +178,6 @@ struct ComposingBufferSize {
|
|||
defaults.removeObject(forKey: kCandidateKeyLabelFontName)
|
||||
defaults.removeObject(forKey: kCandidateKeys)
|
||||
defaults.removeObject(forKey: kPhraseReplacementEnabled)
|
||||
defaults.removeObject(forKey: kChineseConversionEngine)
|
||||
defaults.removeObject(forKey: kUseWinNT351BPMF)
|
||||
defaults.removeObject(forKey: kMaxCandidateLength)
|
||||
defaults.removeObject(forKey: kShouldNotFartInLieuOfBeep)
|
||||
|
@ -430,13 +414,6 @@ struct ComposingBufferSize {
|
|||
|
||||
}
|
||||
|
||||
@UserDefault(key: kChineseConversionEngine, defaultValue: 0)
|
||||
@objc static var chineseConversionEngine: Int
|
||||
|
||||
@objc static var chineseConversionEngineName: String? {
|
||||
return ChineseConversionEngine(rawValue: chineseConversionEngine)?.name
|
||||
}
|
||||
|
||||
@UserDefault(key: kPhraseReplacementEnabled, defaultValue: false)
|
||||
@objc static var phraseReplacementEnabled: Bool
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ extension RangeReplaceableCollection where Element: Hashable {
|
|||
basisKeyboardLayoutButton.menu?.removeAllItems()
|
||||
|
||||
let basisKeyboardLayoutID = Preferences.basisKeyboardLayout
|
||||
|
||||
for source in list {
|
||||
|
||||
func getString(_ key: CFString) -> String? {
|
||||
|
@ -112,20 +113,6 @@ extension RangeReplaceableCollection where Element: Hashable {
|
|||
menuItem.title = localizedName
|
||||
menuItem.representedObject = sourceID
|
||||
|
||||
if let iconPtr = TISGetInputSourceProperty(source, kTISPropertyIconRef) {
|
||||
let icon = IconRef(iconPtr)
|
||||
let image = NSImage(iconRef: icon)
|
||||
|
||||
func resize( _ image: NSImage) -> NSImage {
|
||||
let newImage = NSImage(size: NSSize(width: 16, height: 16))
|
||||
newImage.lockFocus()
|
||||
image.draw(in: NSRect(x: 0, y: 0, width: 16, height: 16))
|
||||
newImage.unlockFocus()
|
||||
return newImage
|
||||
}
|
||||
menuItem.image = resize(image)
|
||||
}
|
||||
|
||||
if sourceID == "com.apple.keylayout.US" {
|
||||
usKeyboardLayoutItem = menuItem
|
||||
}
|
||||
|
@ -135,6 +122,11 @@ extension RangeReplaceableCollection where Element: Hashable {
|
|||
basisKeyboardLayoutButton.menu?.addItem(menuItem)
|
||||
}
|
||||
|
||||
let menuItem = NSMenuItem()
|
||||
menuItem.title = String(format: NSLocalizedString("Apple Zhuyin Bopomofo", comment: ""))
|
||||
menuItem.representedObject = String("com.apple.keylayout.ZhuyinBopomofo")
|
||||
basisKeyboardLayoutButton.menu?.addItem(menuItem)
|
||||
|
||||
basisKeyboardLayoutButton.select(chosenItem ?? usKeyboardLayoutItem)
|
||||
selectionKeyComboBox.usesDataSource = false
|
||||
selectionKeyComboBox.removeAllItems()
|
||||
|
|
|
@ -43,3 +43,4 @@
|
|||
"zh-Hans" = "Simplified Chinese";
|
||||
"zh-Hant" = "Traditional Chinese";
|
||||
"ja" = "Japanese";
|
||||
"Apple Zhuyin Bopomofo" = "Apple Zhuyin Bopomofo";
|
||||
|
|
|
@ -43,3 +43,4 @@
|
|||
"zh-Hans" = "簡體中国語";
|
||||
"zh-Hant" = "繁體中国語";
|
||||
"ja" = "和語";
|
||||
"Apple Zhuyin Bopomofo" = "Apple 注音ボポモフォ配列";
|
||||
|
|
|
@ -43,3 +43,4 @@
|
|||
"zh-Hans" = "简体中文";
|
||||
"zh-Hant" = "繁体中文";
|
||||
"ja" = "和文";
|
||||
"Apple Zhuyin Bopomofo" = "Apple 注音键盘布局";
|
||||
|
|
|
@ -43,3 +43,5 @@
|
|||
"zh-Hans" = "簡體中文";
|
||||
"zh-Hant" = "繁體中文";
|
||||
"ja" = "和文";
|
||||
"Apple Zhuyin Bopomofo" = "Apple Zhuyin Bopomofo";
|
||||
"Apple Zhuyin Bopomofo" = "Apple 注音鍵盤佈局";
|
||||
|
|
Loading…
Reference in New Issue