IMEApp // Implement .isKeyboardJIS().

This commit is contained in:
ShikiSuen 2023-09-15 18:02:49 +08:00
parent 63422c9841
commit 153572b826
3 changed files with 8 additions and 4 deletions

View File

@ -7,6 +7,7 @@
// requirements defined in MIT License. // requirements defined in MIT License.
import AppKit import AppKit
import Carbon
import Shared import Shared
// MARK: - Top-level Enums relating to Input Mode and Language Supports. // MARK: - Top-level Enums relating to Input Mode and Language Supports.
@ -58,6 +59,11 @@ public enum IMEApp {
.init(rawValue: PrefMgr.shared.mostRecentInputMode) ?? .imeModeNULL .init(rawValue: PrefMgr.shared.mostRecentInputMode) ?? .imeModeNULL
} }
/// JIS
public static var isKeyboardJIS: Bool {
KBGetLayoutType(Int16(LMGetKbdType())) == kKeyboardJIS
}
/// Fart or Beep? /// Fart or Beep?
public static func buzz() { public static func buzz() {
if PrefMgr.shared.isDebugModeEnabled { if PrefMgr.shared.isDebugModeEnabled {

View File

@ -232,8 +232,7 @@ extension InputHandler {
let ctrlShiftCMD: Bool = input.keyModifierFlags == [.control, .command, .shift] let ctrlShiftCMD: Bool = input.keyModifierFlags == [.control, .command, .shift]
if ctrlShiftCMD || ctrlCMD { if ctrlShiftCMD || ctrlCMD {
// JIS US // JIS US
let isJIS: Bool = KBGetLayoutType(Int16(LMGetKbdType())) == kKeyboardJIS switch (input.keyCode, IMEApp.isKeyboardJIS) {
switch (input.keyCode, isJIS) {
case (30, true), (33, false): case (30, true), (33, false):
_ = ctlCandidate.highlightPreviousCandidate() ? {}() : delegate.callError("8B144DCD") _ = ctlCandidate.highlightPreviousCandidate() ? {}() : delegate.callError("8B144DCD")
return true return true

View File

@ -164,8 +164,7 @@ public extension InputHandler {
revolveCandidateWithBrackets: if ctrlShiftCMD || ctrlCMD { revolveCandidateWithBrackets: if ctrlShiftCMD || ctrlCMD {
if state.type != .ofInputting { break revolveCandidateWithBrackets } if state.type != .ofInputting { break revolveCandidateWithBrackets }
// JIS US // JIS US
let isJIS: Bool = KBGetLayoutType(Int16(LMGetKbdType())) == kKeyboardJIS switch (input.keyCode, IMEApp.isKeyboardJIS) {
switch (input.keyCode, isJIS) {
case (30, true), (33, false): return revolveCandidate(reverseOrder: true) case (30, true), (33, false): return revolveCandidate(reverseOrder: true)
case (42, true), (30, false): return revolveCandidate(reverseOrder: false) case (42, true), (30, false): return revolveCandidate(reverseOrder: false)
default: break default: break