Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfd095b3b0 | ||
|
|
f323a29552 |
@@ -15,9 +15,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.13.1</string>
|
||||
<string>0.13.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>22</string>
|
||||
<string>23</string>
|
||||
<key>ComponentInputModeDict</key>
|
||||
<dict>
|
||||
<key>tsInputModeListKey</key>
|
||||
|
||||
@@ -15,18 +15,25 @@ enum InputModes {
|
||||
return list.first
|
||||
}
|
||||
|
||||
/// Makes the given mode current (enabling it first if needed). Returns false on failure.
|
||||
private static func isEnabled(_ src: TISInputSource) -> Bool {
|
||||
guard let p = TISGetInputSourceProperty(src, kTISPropertyInputSourceIsEnabled) else { return false }
|
||||
return CFBooleanGetValue(Unmanaged<CFBoolean>.fromOpaque(p).takeUnretainedValue())
|
||||
}
|
||||
|
||||
/// Makes the given mode current. Returns false on failure.
|
||||
/// Only enables the mode if it is not enabled yet: TISEnableInputSource opens System
|
||||
/// Settings → Keyboard, even for a source that is already enabled.
|
||||
@discardableResult
|
||||
static func select(english: Bool) -> Bool {
|
||||
guard let src = source(english ? InputModes.english : InputModes.auto) else { return false }
|
||||
TISEnableInputSource(src)
|
||||
if !isEnabled(src) { TISEnableInputSource(src) }
|
||||
return TISSelectInputSource(src) == noErr
|
||||
}
|
||||
|
||||
/// Called by `--register`: enable both modes so they are in the input menu.
|
||||
/// Called by `--register`: enable both modes (if not yet) so they are in the input menu.
|
||||
static func enableAll() {
|
||||
for id in [auto, english] {
|
||||
if let src = source(id) { TISEnableInputSource(src) }
|
||||
if let src = source(id), !isEnabled(src) { TISEnableInputSource(src) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "自動注音 AutoZhuyin",
|
||||
"version": "0.13.1",
|
||||
"version": "0.13.2",
|
||||
"guid": "{3895C6E3-6D40-4B4B-B4EA-CEEC75382D23}",
|
||||
"locale": "zh-Hant-TW",
|
||||
"fallbackLocale": "zh-TW",
|
||||
|
||||
Reference in New Issue
Block a user