Permalink
Browse files

Refactoring

  • Loading branch information...
youknowone committed Jan 15, 2019
1 parent bc3833e commit 3d178e1426a15b7d3b5e59c60452e0e6eb44687a

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -55,7 +55,7 @@ class GureumTests: XCTestCase {
for app in apps {
app.client.string = ""
app.controller.setValue("org.youknowone.inputmethod.Gureum.qwerty", forTag: kTextServiceInputModePropertyTag, client: app.client)
app.inputText(nil, key: -1, modifiers: NSEvent.ModifierFlags.capsLock)
app.inputFlags(NSEvent.ModifierFlags.capsLock)

app.inputText(" ", key: Int(kVK_Space), modifiers: NSEvent.ModifierFlags.shift)
app.inputText(" ", key: Int(kVK_Space), modifiers: NSEvent.ModifierFlags.shift)
@@ -426,7 +426,7 @@ class GureumTests: XCTestCase {
app.client.string = ""
app.controller.setValue(GureumInputSourceIdentifier.qwerty.rawValue, forTag: kTextServiceInputModePropertyTag, client: app.client)

let composer = app.controller.composer as! GureumComposer
let composer = app.controller.receiver.composer as! GureumComposer
let emoticonComposer = composer.emoticonComposer
emoticonComposer.delegate = composer.delegate // roman?
composer.delegate = emoticonComposer
@@ -10,14 +10,20 @@ import Foundation
@testable import GureumCore

class VirtualApp: NSObject {
let controller: CIMInputController
let controller: MockInputController
let client = MockInputClient()

override init() {
controller = CIMMockInputController(server: InputMethodServer.shared.server, delegate: client, client: client)
controller = MockInputController(server: InputMethodServer.shared.server, delegate: client, client: client)
super.init()
}

func inputFlags(_ flags: NSEvent.ModifierFlags) -> Bool {
let processed = controller.inputFlags(Int(flags.rawValue), client: client)
controller.updateComposition()
return processed
}

func inputText(_ string: String!, key keyCode: Int, modifiers flags: NSEvent.ModifierFlags) -> Bool {
let processed = controller.inputText(string, key: keyCode, modifiers: Int(flags.rawValue), client: client)
controller.updateComposition()
@@ -1,5 +1,5 @@
//
// CIMInputController.m
// InputController.m
// Gureum
//
// Created by youknowone on 11. 8. 31..
@@ -34,10 +34,10 @@ class NotificationCenterDelegate: NSObject, NSUserNotificationCenterDelegate {
}
}

class GureumAppDelegate: NSObject, NSApplicationDelegate, CIMApplicationDelegate {
class GureumAppDelegate: NSObject, NSApplicationDelegate, GureumApplicationDelegate {
@IBOutlet @objc var menu: NSMenu!

let configuration = GureumConfiguration.shared
let configuration = Configuration.shared
let notificationCenterDelegate = NotificationCenterDelegate()

func applicationDidFinishLaunching(_ notification: Notification) {
@@ -55,8 +55,7 @@ class GureumAppDelegate: NSObject, NSApplicationDelegate, CIMApplicationDelegate
Fabric.with([Crashlytics.self])
#endif

let updateManager = UpdateManager.shared
updateManager.notifyUpdateIfNeeded()
UpdateManager.shared.notifyUpdateIfNeeded()

// IMKServer를 띄워야만 입력기가 동작한다
_ = InputMethodServer.shared
@@ -1,5 +1,5 @@
//
// CIMInputControllerGureum.swift
// InputControllerGureum.swift
// Gureum
//
// Created by KMLee on 2018. 8. 24..
@@ -10,7 +10,7 @@ import Cocoa
import Foundation
import GureumCore

extension CIMInputController {
extension GureumAppDelegate {
@IBAction func checkRecentVersion(_: Any) {
guard let info = UpdateManager.shared.requestRecentVersion() else {
return
@@ -442,9 +442,9 @@
<key>InputMethodConnectionName</key>
<string>GureumInputMethod_1_Connection</string>
<key>InputMethodServerControllerClass</key>
<string>CIMInputController</string>
<string>GureumInputController</string>
<key>InputMethodServerDelegateClass</key>
<string>CIMInputController</string>
<string>GureumInputController</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14113" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"/>
@@ -17,44 +17,40 @@
<outlet property="menu" destination="538" id="544"/>
</connections>
</customObject>
<customObject id="550" customClass="CIMInputController"/>
<menu id="538">
<items>
<menuItem title="구름 입력기에 관하여" id="539">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="showStandardAboutPanel:" target="550" id="552"/>
</connections>
</menuItem>
<menuItem title="업데이트 확인" id="557">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="checkRecentVersion:" target="550" id="566"/>
<action selector="checkRecentVersion:" target="494" id="iAc-Fb-XKV"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="561"/>
<menuItem title="웹사이트..." id="555">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openWebsite:" target="550" id="567"/>
<action selector="openWebsite:" target="494" id="qXD-LJ-2eV"/>
</connections>
</menuItem>
<menuItem title=" 도움말..." id="553">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openWebsiteHelp:" target="550" id="568"/>
<action selector="openWebsiteHelp:" target="494" id="3GP-kp-Nx0"/>
</connections>
</menuItem>
<menuItem title=" 버그 알리기..." id="564">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openWebsiteIssues:" target="550" id="569"/>
<action selector="openWebsiteIssues:" target="494" id="eEb-ZD-TRB"/>
</connections>
</menuItem>
<menuItem title=" 소스 코드..." id="562">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openWebsiteSource:" target="550" id="570"/>
<action selector="openWebsiteSource:" target="494" id="9e7-Ql-FjA"/>
</connections>
</menuItem>
</items>
@@ -1,5 +1,5 @@
//
// CIMBaseComposer.swift
// BaseComposer.swift
// Gureum
//
// Created by 김민주 on 2018. 9. 1..
@@ -9,7 +9,7 @@
import Cocoa
import Foundation

class CIMBaseComposer {
class BaseComposer {
func composedString() -> NSString {
return ""
}
@@ -22,7 +22,7 @@ class CIMBaseComposer {
return ""
}

func dequeueCommitString() -> NSString {
func dequeueCommitString() -> String {
return ""
}

@@ -36,7 +36,7 @@ class CIMBaseComposer {
return nil
}

func input(controller _: CIMInputController!, command _: String!, key _: Int, modifier _: NSEvent.ModifierFlags, client _: Any) -> CIMInputTextProcessResult {
return CIMInputTextProcessResult.notProcessed
func input(controller _: InputController!, command _: String!, key _: Int, modifier _: NSEvent.ModifierFlags, client _: Any) -> InputResult {
return .notProcessed
}
}
@@ -1,5 +1,5 @@
//
// CIMComposer.swift
// DelegatedComposer.swift
// OSX
//
// Created by Jeong YunWon on 20/10/2018.
@@ -12,9 +12,9 @@ import Foundation
/*!
@protocol
@brief 입력을 처리하는 클래스의 관한 공통 형식
@discussion TextData형식으로 @ref IMKServerInput 을 처리할 클래스의 공통 인터페이스. CharmIM에서 입력 값을 보고 처리하는 모든 클래스는 이 프로토콜을 구현한다.
@discussion TextData형식으로 @ref IMKServerInput 을 처리할 클래스의 공통 인터페이스. 입력 값을 보고 처리하는 모든 클래스는 이 프로토콜을 구현한다.
*/
protocol CIMInputTextDelegate {
protocol InputTextDelegate {
/*!
@method
@param controller 서버에서 입력을 받은 컨트롤러
@@ -25,15 +25,15 @@ protocol CIMInputTextDelegate {
@return 입력 처리 여부. YES를 반환하면 이미 처리된 입력으로 보고 NO를 반환하면 외부에서 입력을 다시 처리한다.
@see IMKServerInput
*/
func input(controller: CIMInputController, inputText: String?, key: Int, modifiers: NSEvent.ModifierFlags, client: Any) -> CIMInputTextProcessResult
func input(text: String?, key: Int, modifiers: NSEvent.ModifierFlags, client: Any) -> InputResult
}

/*!
@brief 실제로 문자를 합성하는 합성기의 프로토콜
@discussion 입력기 전체의 상태에 영향을 끼치는 처리를 마친 후 출력할 글자를 조합하기 위해 CIMComposer로 입력을 전달한다. 기본적으로 자판마다 하나씩 구현하게 된다.
@discussion 입력기 전체의 상태에 영향을 끼치는 처리를 마친 후 출력할 글자를 조합하기 위해 DelegatedComposer로 입력을 전달한다. 기본적으로 자판마다 하나씩 구현하게 된다.
*/

protocol CIMComposerDelegate: CIMInputTextDelegate {
protocol ComposerDelegate: InputTextDelegate {
//! @brief 입력기가 선택 됨
func composerSelected(_ sender: Any!)

@@ -59,23 +59,18 @@ protocol CIMComposerDelegate: CIMInputTextDelegate {
func candidateSelected(_ candidateString: NSAttributedString)
//! @brief 변환 후보 문자열 변경
func candidateSelectionChanged(_ candidateString: NSAttributedString)

func input(controller: CIMInputController, command string: String?, key keyCode: Int, modifiers flags: NSEvent.ModifierFlags, client: Any) -> CIMInputTextProcessResult
}

/*!
@brief 일반적인 합성기 구조
@warning 이 자체로는 동작하지 않는다. 상속하여 동작을 구현하거나 @ref CIMBaseComposer 를 사용한다.
@warning 이 자체로는 동작하지 않는다. 상속하여 동작을 구현하거나 @ref BaseComposer 를 사용한다.
*/
class CIMComposer: NSObject, CIMComposerDelegate {
class DelegatedComposer: ComposerDelegate {
func composerSelected(_: Any!) {}

var delegate: CIMComposerDelegate!
var delegate: ComposerDelegate!
var inputMode: String = ""
var server: InputMethodServer {
return InputMethodServer.shared
}

var composedString: String {
return delegate.composedString
@@ -117,11 +112,7 @@ class CIMComposer: NSObject, CIMComposerDelegate {
return delegate.candidateSelectionChanged(candidateString)
}

func input(controller: CIMInputController, inputText string: String?, key keyCode: Int, modifiers flags: NSEvent.ModifierFlags, client sender: Any) -> CIMInputTextProcessResult {
return delegate.input(controller: controller, inputText: string, key: keyCode, modifiers: flags, client: sender)
}

func input(controller: CIMInputController, command string: String?, key keyCode: Int, modifiers flags: NSEvent.ModifierFlags, client sender: Any) -> CIMInputTextProcessResult {
return delegate.input(controller: controller, command: string, key: keyCode, modifiers: flags, client: sender)
func input(text string: String?, key keyCode: Int, modifiers flags: NSEvent.ModifierFlags, client sender: Any) -> InputResult {
return delegate.input(text: string, key: keyCode, modifiers: flags, client: sender)
}
}
Oops, something went wrong.

0 comments on commit 3d178e1

Please sign in to comment.