Fix Cmd key regression

Shift and Alt modifiers now register in combination with Cmd and e.g.
arrow keys.
This commit is contained in:
Bjorn Winckler
2009-08-27 17:41:42 +02:00
parent 2d7c78f24c
commit 7cae9e965c
2 changed files with 15 additions and 16 deletions
+13 -2
View File
@@ -1954,8 +1954,19 @@ static void netbeansReadCallback(CFSocketRef s,
if (mods & MOD_MASK_CMD) {
// NOTE: For normal input (non-special, 'macmeta' off) the modifier
// flags are already included in the key event. However, the Cmd key
// flag is special and must always be added manually. The frontend is
// responsible for clearing unnecessary flags when Cmd is held.
// flag is special and must always be added manually.
// The Shift flag is already included in the key when the Command
// key is held. The same goes for Alt, unless Ctrl is held or
// 'macmeta' is set. It is important that these flags are cleared
// _after_ special keys have been handled, since they should never be
// cleared for special keys.
mods &= ~MOD_MASK_SHIFT;
if (!(mods & MOD_MASK_CTRL)) {
BOOL mmta = curbuf ? curbuf->b_p_mmta : YES;
if (!mmta)
mods &= ~MOD_MASK_ALT;
}
ASLogDebug(@"add mods=%#x", mods);
char_u modChars[3] = { CSI, KS_MODIFIER, mods };
add_to_input_buf(modChars, 3);
+2 -14
View File
@@ -162,8 +162,8 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
// HACK! When Command is held we have to more or less guess whether
// we should use characters or charactersIgnoringModifiers. The
// following heuristic seems to work but it may have to change.
// Note that the Shift and Alt flags may be cleared before passing
// the event on to Vim (see doKeyDown:).
// Note that the Shift and Alt flags may also need to be cleared
// (see doKeyDown:keyCode:modifiers: in MMBackend).
if ((flags & NSShiftKeyMask && !(flags & NSAlternateKeyMask))
|| flags & NSControlKeyMask)
string = unmod;
@@ -897,18 +897,6 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
unsigned keyCode = [currentEvent keyCode];
unsigned flags = [currentEvent modifierFlags];
if (flags & NSCommandKeyMask) {
// The Shift flag is already included in the key when the Command key
// is held. The same goes for Alt, unless Ctrl is held or 'macmeta' is
// set.
flags &= ~NSShiftKeyMask;
if (!(flags & NSControlKeyMask)) {
id mmta = [[[self vimController] vimState] objectForKey:@"p_mmta"];
if (![mmta boolValue])
flags &= ~NSAlternateKeyMask;
}
}
// The low 16 bits are not used for modifier flags by NSEvent. Use
// these bits for custom flags.
flags &= NSDeviceIndependentModifierFlagsMask;