Permalink
Browse files

Merge pull request #501 from youknowone/test-app

 TestApp 삭제 지원
  • Loading branch information...
youknowone committed Jan 19, 2019
2 parents 0ea1e43 + 8c028e3 commit 0dce7c4e6cb640cdc8ff05c03b97e5b242b9ca62
Showing with 31 additions and 10 deletions.
  1. +2 −6 OSXCore/InputController.swift
  2. +1 −1 OSXCore/InputReceiver.swift
  3. +28 −3 OSXTestApp/TestViewController.swift
@@ -178,7 +178,7 @@ public extension InputController { // IMKStateSetting

override func deactivateServer(_ sender: Any!) {
dlog(true, "server deactivating")
receiver.commitCompositionEvent(sender)
commitComposition(sender)
super.deactivateServer(sender)
}
}
@@ -206,7 +206,7 @@ public extension InputController { // IMKServerInput
@objc override func commitComposition(_ sender: Any!) {
dlog(DEBUG_LOGGING, "LOGGING::EVENT::COMMIT-RAW?")
_ = receiver.commitCompositionEvent(sender)
super.commitComposition(sender)
// super.commitComposition(sender)
}

@objc override func updateComposition() {
@@ -311,10 +311,6 @@ public extension InputController { // IMKServerInput
if markedRange.length > 0 || newMarkedRange.length > 0 {
let view = receiver.inputClient as! NSTextView
view.setMarkedText(composed, selectedRange: newMarkedRange, replacementRange: markedRange)
let hasMarked1 = view.hasMarkedText()
view.setSelectedRange(newMarkedRange)
let hasMarked2 = view.hasMarkedText()
assert(hasMarked1 == hasMarked2)
}
}

@@ -183,7 +183,7 @@ extension InputReceiver { // IMKServerInput
}

dlog(DEBUG_INPUT_RECEIVER, "** InputController -commitComposition: with sender: %@ / strings: %@", sender as! NSObject, commitString)
let range = controller.selectionRange()
let range = (sender as! IMKTextInput).markedRange()
dlog(DEBUG_LOGGING, "LOGGING::COMMIT::%lu:%lu:%@", range.location, range.length, commitString)
if range.length > 0 {
controller.client().insertText(commitString, replacementRange: range)
@@ -36,12 +36,37 @@ class TestViewController: NSViewController {
// print(event)
assert(self.inputController != nil)
assert(self.inputClient != nil)
guard event.type == .keyDown else {
_ = self.inputController.handle(event, client: self.inputClient)
return nil
}
if event.keyCode == kVK_Delete, self.inputClient.selectedRange().length > 0 {
self.inputClient.insertText(event.characters, replacementRange: self.inputClient.selectedRange())
return nil
}
let processed = self.inputController.handle(event, client: self.inputClient)
if processed {
return nil
}
let specialFlags = event.modifierFlags.intersection([.command, .control])
if event.type == .keyDown, !processed, specialFlags.isEmpty {
self.inputClient.insertText(event.characters, replacementRange: self.inputClient.markedRange())
if !processed, specialFlags.isEmpty {
if event.keyCode == kVK_Delete {
NSLog("\(self.inputClient.selectedRange())")
if self.inputClient.hasMarkedText() {
self.inputClient.insertText(event.characters, replacementRange: self.inputClient.markedRange())
} else {
let marked = self.inputClient.markedRange()
let deleted = NSRange(location: marked.location - 1, length: 1)
self.inputClient.insertText(event.characters, replacementRange: deleted)
let marking = NSRange(location: marked.location - 1, length: 0)
self.inputClient.setMarkedText("", selectionRange: marking, replacementRange: deleted)
}
} else {
self.inputClient.insertText(event.characters, replacementRange: self.inputClient.markedRange())
}
return nil
}
return nil
return event
})
}
}

0 comments on commit 0dce7c4

Please sign in to comment.