Permalink
Browse files

Merge pull request #448 from adover134/fix-vi-mode

Mapped Vi-mode's Escape with Ctrl+'['
  • Loading branch information...
youknowone committed Dec 6, 2018
2 parents 34ae616 + 62cea10 commit 3e9920247148a03cdf51377297ccaafbee030e88
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 3e99202

Please sign in to comment.