Skip to content

Commit

Permalink
Basic implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ensan-hcl committed Mar 18, 2024
1 parent 3b0db38 commit 65c9d97
Show file tree
Hide file tree
Showing 21 changed files with 503 additions and 130 deletions.
22 changes: 0 additions & 22 deletions IMKitSample/IMKitSampleInputController.swift

This file was deleted.

Binary file removed IMKitSample/main.tiff
Binary file not shown.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ To try this sample project, follow these steps:
* Open this project in Xcode.
* Run the project.
* In the terminal, type `sudo chmod -R 777 /Library/Input\ Methods`.
* Add 'IMKitSample' under **Settings** > **Keyboard** > **Input Sources** > **English**.
* Choose IMKitSample as the input source and try it on a text field.
* Add 'azooKeyMac' under **Settings** > **Keyboard** > **Input Sources** > **English**.
* Choose azooKeyMac as the input source and try it on a text field.

## Procedure to make project
I used the following steps to prepare this sample project:

* Create a new project with a bundle identifier that contains `.inputmethod.` in the string.
* Run the project.
* Remove `IMKitSampleApp.swift` and `ContentView.swift`.
* Remove `azooKeyMacApp.swift` and `ContentView.swift`.

* Add Swift files `AppDelegate.swift` and `IMKitSampleInputController.swift`.
* Add Swift files `AppDelegate.swift` and `azooKeyMacInputController.swift`.

```swift
// AppDelegate.swift
Expand Down Expand Up @@ -70,12 +70,12 @@ I used the following steps to prepare this sample project:
```

```swift
// IMKitSampleInputController.swift
// azooKeyMacInputController.swift
import Cocoa
import InputMethodKit

@objc(IMKitSampleInputController)
class IMKitSampleInputController: IMKInputController {
@objc(azooKeyMacInputController)
class azooKeyMacInputController: IMKInputController {
override func inputText(_ string: String!, client sender: Any!) -> Bool {
NSLog(string)
// get client to insert
Expand All @@ -94,7 +94,7 @@ I used the following steps to prepare this sample project:
```
key: NSPrincipalClass type: _ value: $(PRODUCT_MODULE_NAME).NSManualApplication
key: InputMethodConnectionName type: String value: $(PRODUCT_BUNDLE_IDENTIFIER)_Connection
key: InputMethodServerControllerClass type: String value: $(PRODUCT_MODULE_NAME).IMKitSampleInputController
key: InputMethodServerControllerClass type: String value: $(PRODUCT_MODULE_NAME).azooKeyMacInputController
key: Application is background only type: Boolean value: YES
key: tsInputMethodCharacterRepertoireKey type: Array value: [item0: String = Latn]
key: tsInputMethodIconFileKey type: String value: main.tiff
Expand All @@ -104,7 +104,7 @@ I used the following steps to prepare this sample project:

* Go **Signing & Capabilities****+Capability****App Sandbox**

* Go IMKitSample.entitlements, add
* Go azooKeyMac.entitlements, add

```
key: com.apple.security.temporary-exception.mach-register.global-name
Expand Down

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions azooKeyMac.xcodeproj/xcshareddata/xcschemes/azooKeyMac.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A41E61326E745D9009B65D7"
BuildableName = "azooKeyMac.app"
BlueprintName = "azooKeyMac"
ReferencedContainer = "container:azooKeyMac.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A41E62326E745DD009B65D7"
BuildableName = "azooKeyMacTests.xctest"
BlueprintName = "azooKeyMacTests"
ReferencedContainer = "container:azooKeyMac.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A41E62D26E745DD009B65D7"
BuildableName = "azooKeyMacUITests.xctest"
BlueprintName = "azooKeyMacUITests"
ReferencedContainer = "container:azooKeyMac.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A41E61326E745D9009B65D7"
BuildableName = "azooKeyMac.app"
BlueprintName = "azooKeyMac"
ReferencedContainer = "container:azooKeyMac.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A41E61326E745D9009B65D7"
BuildableName = "azooKeyMac.app"
BlueprintName = "azooKeyMac"
ReferencedContainer = "container:azooKeyMac.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {

func applicationDidFinishLaunching(_ notification: Notification) {
// Insert code here to initialize your application
server = IMKServer(name: Bundle.main.infoDictionary?["InputMethodConnectionName"] as? String, bundleIdentifier: Bundle.main.bundleIdentifier)
candidatesWindow = IMKCandidates(server: server, panelType: kIMKSingleRowSteppingCandidatePanel, styleType: kIMKMain)
self.server = IMKServer(name: Bundle.main.infoDictionary?["InputMethodConnectionName"] as? String, bundleIdentifier: Bundle.main.bundleIdentifier)
self.candidatesWindow = IMKCandidates(server: server, panelType: kIMKSingleRowSteppingCandidatePanel, styleType: kIMKMain)
NSLog("tried connection")
}

Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions azooKeyMac/Extensions/NSRange.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// NSRange.swift
// azooKeyMac
//
// Created by miwa on 2024/03/18.
//

import Foundation

extension NSRange {
static var notFound: NSRange {
NSRange(location: NSNotFound, length: NSNotFound)
}
}
6 changes: 5 additions & 1 deletion IMKitSample/Info.plist → azooKeyMac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>TISIntendedLanguage</key>
<string>ja</string>
<key>NSPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).NSManualApplication</string>
<key>InputMethodConnectionName</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)_Connection</string>
<key>InputMethodServerControllerClass</key>
<string>$(PRODUCT_MODULE_NAME).IMKitSampleInputController</string>
<string>$(PRODUCT_MODULE_NAME).azooKeyMacInputController</string>
<key>LSBackgroundOnly</key>
<true/>
<key>tsInputMethodCharacterRepertoireKey</key>
<array>
<string>Kana</string>
<string>Hira</string>
<string>Latn</string>
</array>
<key>tsInputMethodIconFileKey</key>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// IMKitSampleApp.swift
// IMKitSample
// azooKeyMacApp.swift
// azooKeyMac
//
// Created by ensan on 2021/09/07.
//

import SwiftUI

struct IMKitSampleApp: App {
struct azooKeyMacApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
Expand Down
Loading

0 comments on commit 65c9d97

Please sign in to comment.