Skip to content

Updated to work with macOS 13 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

slavenskoj
Copy link

Updated code for macOS 13 and above, replacing the deprecated scanCharacters(from:into:) method:

let charset = CharacterSet.alphanumerics.union(.punctuationCharacters).union(.symbols)
if Scanner(string: string).scanCharacters(from: charset) == nil {
    NSLog("control code!")
    if romanBuffer.isEmpty, kanaBuffer.isEmpty { return false }
    var handled = true
    switch keyCode {
    case 0x33:  // delete key
        deleteBackward(client: client)
        return true
    case 0x24:  // enter key
        handled = false
    case 0x31:  // space
        receive(string: " ", client: client)
    case 0x30:  // tab key
        fixTrailingN(client: client)
    default:
        NSLog("Unexpected Input: keyCode(%lX) flags(%lX)", keyCode, flags.rawValue)
        handled = false
    }
    commitComposition(client: client)
    return handled
}

In macOS 10.15 and later, the newer scanCharacters(from:) method returns a String? value directly rather than using an into parameter. The method returns nil if no matching characters are found, which maintains the same logic as the original code.

Updated code for macOS 13 and above, replacing the deprecated scanCharacters(from:into:) method. In macOS 10.15 and later, the newer scanCharacters(from:) method returns a String? value directly rather than using an into parameter. The method returns nil if no matching characters are found, which maintains the same logic as the original code.
@slavenskoj slavenskoj changed the title Updated to work with macOS 14 Updated to work with macOS 13 Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant