Refactors the keyboard layout enum.
This commit is contained in:
parent
83354f7c48
commit
d11daacbd2
|
@ -228,29 +228,28 @@ static double FindHighestScore(const vector<NodeAnchor>& nodes, double epsilon)
|
||||||
[_composingBuffer setString:@""];
|
[_composingBuffer setString:@""];
|
||||||
|
|
||||||
// checks and populates the default settings
|
// checks and populates the default settings
|
||||||
NSInteger keyboardLayout = Preferences.keyboardLayout;
|
switch (Preferences.keyboardLayout) {
|
||||||
switch (keyboardLayout) {
|
case KeyboardLayoutStandard:
|
||||||
case 0:
|
|
||||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::StandardLayout());
|
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::StandardLayout());
|
||||||
break;
|
break;
|
||||||
case 1:
|
case KeyboardLayoutEten:
|
||||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::ETenLayout());
|
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::ETenLayout());
|
||||||
break;
|
break;
|
||||||
case 2:
|
case KeyboardLayoutHsu:
|
||||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::HsuLayout());
|
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::HsuLayout());
|
||||||
break;
|
break;
|
||||||
case 3:
|
case KeyboardLayoutEten26:
|
||||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::ETen26Layout());
|
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::ETen26Layout());
|
||||||
break;
|
break;
|
||||||
case 4:
|
case KeyboardLayoutHanyuPinyin:
|
||||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::HanyuPinyinLayout());
|
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::HanyuPinyinLayout());
|
||||||
break;
|
break;
|
||||||
case 5:
|
case KeyboardLayoutIBM:
|
||||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::IBMLayout());
|
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::IBMLayout());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::StandardLayout());
|
_bpmfReadingBuffer->setKeyboardLayout(BopomofoKeyboardLayout::StandardLayout());
|
||||||
Preferences.keyboardLayout = 0;
|
Preferences.keyboardLayout = KeyboardLayoutStandard;
|
||||||
}
|
}
|
||||||
|
|
||||||
[(AppDelegate *)[NSApp delegate] checkForUpdate];
|
[(AppDelegate *)[NSApp delegate] checkForUpdate];
|
||||||
|
|
|
@ -173,30 +173,42 @@ struct ComposingKeys {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: -
|
||||||
|
|
||||||
|
@objc enum KeyboardLayout: Int {
|
||||||
|
case standard
|
||||||
|
case eten
|
||||||
|
case eten26
|
||||||
|
case hsu
|
||||||
|
case hanyuPinyin
|
||||||
|
case IBM
|
||||||
|
|
||||||
|
var name: String {
|
||||||
|
switch (self) {
|
||||||
|
case .standard:
|
||||||
|
return "Standard"
|
||||||
|
case .eten:
|
||||||
|
return "ETen"
|
||||||
|
case .eten26:
|
||||||
|
return "ETen26"
|
||||||
|
case .hsu:
|
||||||
|
return "Hsu"
|
||||||
|
case .hanyuPinyin:
|
||||||
|
return "HanyuPinyin"
|
||||||
|
case .IBM:
|
||||||
|
return "IBM"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
||||||
class Preferences: NSObject {
|
class Preferences: NSObject {
|
||||||
@UserDefault(key: kKeyboardLayoutPreferenceKey, defaultValue: 0)
|
@UserDefault(key: kKeyboardLayoutPreferenceKey, defaultValue: KeyboardLayout.standard)
|
||||||
@objc static var keyboardLayout: Int
|
@objc static var keyboardLayout: KeyboardLayout
|
||||||
|
|
||||||
@objc static var keyboardLayoutName: String {
|
@objc static var keyboardLayoutName: String {
|
||||||
switch self.keyboardLayout {
|
self.keyboardLayout.name
|
||||||
case 0:
|
|
||||||
return "Standard"
|
|
||||||
case 1:
|
|
||||||
return "ETen"
|
|
||||||
case 2:
|
|
||||||
return "ETen26"
|
|
||||||
case 3:
|
|
||||||
return "Hsu"
|
|
||||||
case 4:
|
|
||||||
return "HanyuPinyin"
|
|
||||||
case 5:
|
|
||||||
return "IBM"
|
|
||||||
default:
|
|
||||||
return "Standard"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserDefault(key: kBasisKeyboardLayoutPreferenceKey, defaultValue: "com.apple.keylayout.US")
|
@UserDefault(key: kBasisKeyboardLayoutPreferenceKey, defaultValue: "com.apple.keylayout.US")
|
||||||
|
|
Loading…
Reference in New Issue