mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Merge pull request #786 from ichizok/fix/ctrl-6
Fix the working of Ctrl-6
This commit is contained in:
@@ -170,21 +170,34 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
|
||||
&& [unmod length] == 1
|
||||
&& ([unmod characterAtIndex:0] == '6' ||
|
||||
[unmod characterAtIndex:0] == '^')) {
|
||||
// HACK! interpretKeyEvents: does not call doCommandBySelector:
|
||||
// HACK! interpretKeyEvents: does not call doCommandBySelector:
|
||||
// with Ctrl-6 or Ctrl-^ when IM is active.
|
||||
[self doKeyDown:@"\x1e"];
|
||||
string = nil;
|
||||
} else {
|
||||
// When using JapaneseIM with "Windows-like shortcuts" turned on,
|
||||
// HACK! When using JapaneseIM with "Windows-like shortcuts" turned on,
|
||||
// interpretKeyEvents: does not call doCommandBySelector: with Ctrl-O
|
||||
// and Ctrl-U (why?), so we cannot handle them at all.
|
||||
// As a workaround, we do not call interpretKeyEvents: when no marked
|
||||
// text and with only control-modifier.
|
||||
if ([self hasMarkedText] || (!modControl || modCommand || modOption)) {
|
||||
// HACK! interpretKeyEvents: may call insertText: or
|
||||
// doCommandBySelector:, or it may swallow the key (most likely the
|
||||
// current input method used it). In the first two cases we have to
|
||||
// manually set the below flag to NO if the key wasn't handled.
|
||||
// As a workaround, we do not call interpretKeyEvents: with Ctrl-O or
|
||||
// Ctrl-U when there is no marked text.
|
||||
BOOL isJapaneseIME = [[[NSTextInputContext currentInputContext]
|
||||
selectedKeyboardInputSource]
|
||||
hasPrefix:@"com.apple.inputmethod.Kotoeri"];
|
||||
BOOL isJapaneseIMCtrlUO = (isJapaneseIME
|
||||
&& (modControl && !modCommand && !modOption)
|
||||
&& ([unmod characterAtIndex:0] == 'o' ||
|
||||
[unmod characterAtIndex:0] == 'u'));
|
||||
|
||||
if ([self hasMarkedText] || !isJapaneseIMCtrlUO) {
|
||||
// interpretKeyEvents: may call insertText: or doCommandBySelector:,
|
||||
// or it may swallow the key (most likely the current input method
|
||||
// used it). In the first two cases we have to manually set the
|
||||
// below flag to NO if the key wasn't handled, which allows us to
|
||||
// manually send the key down event.
|
||||
//
|
||||
// doCommandBySelector: will also perform misc translations such as
|
||||
// Ctrl-6 -> Ctrl-^, so this should not be skipped unless there are
|
||||
// special cases like the Japanese IME Ctrl-U issue.
|
||||
interpretKeyEventsSwallowedKey = YES;
|
||||
[textView interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
if (interpretKeyEventsSwallowedKey)
|
||||
|
||||
Reference in New Issue
Block a user