Permalink
Browse files

Mapped Vi-mode's Escape with Ctrl+'['

  • Loading branch information...
adover134 authored and youknowone committed Nov 24, 2018
1 parent 34ae616 commit 62cea10b9d49a794fcc4eefe9d52b2b784b1bfae
Showing with 25 additions and 1 deletion.
  1. +21 −0 GureumTests/GureumTests.swift
  2. +4 −1 OSX/GureumComposer.swift
@@ -502,4 +502,25 @@ class GureumTests: XCTestCase {
}
}
func testEscapeOrCntrlAndLeftBracketHan3Gureum() {
for app in self.apps {
app.client.string = ""
app.controller.setValue(GureumInputSourceIdentifier.han3FinalNoShift.rawValue, forTag: kTextServiceInputModePropertyTag, client: app.client)
app.inputText("[", key: Int(kVK_ANSI_LeftBracket), modifiers: NSEvent.ModifierFlags.control)
XCTAssertEqual("", app.client.string, "buffer: \(app.client.string) app: \(app)")
}
}
func testEscapeOrCntrlAndLeftBracketWithShiftHan3Gureum() {
for app in self.apps {
let controlAndShift = NSEvent.ModifierFlags.control.union(.shift)
app.client.string = ""
app.controller.setValue(GureumInputSourceIdentifier.han3FinalNoShift.rawValue, forTag: kTextServiceInputModePropertyTag, client: app.client)
app.inputText("[", key: Int(kVK_ANSI_LeftBracket), modifiers: controlAndShift)
XCTAssertEqual("", app.client.string, "buffer: \(app.client.string) app: \(app)")
}
}
}
@@ -261,7 +261,10 @@ let GureumInputSourceToHangulKeyboardIdentifierTable: [GureumInputSourceIdentifi
if self.delegate === hangulComposer {
// Vi-mode: esc로 로마자 키보드로 전환
if GureumConfiguration.shared.romanModeByEscapeKey && keyCode == kVK_Escape {
let controlPressed = !inputModifier.intersection(NSEvent.ModifierFlags.control).isEmpty
let shiftUnpressed = inputModifier.intersection(NSEvent.ModifierFlags.shift).isEmpty
let escapePressed = keyCode == kVK_Escape
if GureumConfiguration.shared.romanModeByEscapeKey && (escapePressed || (keyCode == kVK_ANSI_LeftBracket && shiftUnpressed && controlPressed)) {
self.delegate.cancelComposition()
(sender as AnyObject).selectMode(GureumConfiguration.shared.lastRomanInputMode)
return CIMInputTextProcessResult.notProcessedAndNeedsCommit

0 comments on commit 62cea10

Please sign in to comment.