0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

updated for version 7.0-138

This commit is contained in:
Bram Moolenaar
2006-10-17 10:51:57 +00:00
parent b90daee952
commit adcb9497e8
2 changed files with 132 additions and 149 deletions

View File

@@ -2014,7 +2014,7 @@ gui_mac_doKeyEventCarbon(
void *data) void *data)
{ {
/* Multibyte-friendly key event handler */ /* Multibyte-friendly key event handler */
OSStatus e = -1; OSStatus err = -1;
UInt32 actualSize; UInt32 actualSize;
UniChar *text; UniChar *text;
char_u result[INLINE_KEY_BUFFER_SIZE]; char_u result[INLINE_KEY_BUFFER_SIZE];
@@ -2022,114 +2022,59 @@ gui_mac_doKeyEventCarbon(
UInt32 key_sym; UInt32 key_sym;
char charcode; char charcode;
int key_char; int key_char;
UInt32 modifiers; UInt32 modifiers, vimModifiers;
size_t encLen; size_t encLen;
char_u *to = NULL; char_u *to = NULL;
Boolean isSpecial = FALSE; Boolean isSpecial = FALSE;
int i; int i;
EventRef keyEvent;
/* Mask the mouse (as per user setting) */ /* Mask the mouse (as per user setting) */
if (p_mh) if (p_mh)
ObscureCursor(); ObscureCursor();
do
{
/* Don't use the keys when the dialog wants them. */ /* Don't use the keys when the dialog wants them. */
if (dialog_busy) if (dialog_busy)
break; return eventNotHandledErr;
if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText, if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText,
typeUnicodeText, NULL, 0, &actualSize, NULL)) typeUnicodeText, NULL, 0, &actualSize, NULL))
break; return eventNotHandledErr;
text = (UniChar *)alloc(actualSize); text = (UniChar *)alloc(actualSize);
if (!text)
return eventNotHandledErr;
if (text) err = GetEventParameter(theEvent, kEventParamTextInputSendText,
{ typeUnicodeText, NULL, actualSize, NULL, text);
do require_noerr(err, done);
{
if (noErr != GetEventParameter(theEvent, err = GetEventParameter(theEvent, kEventParamTextInputSendKeyboardEvent,
kEventParamTextInputSendText, typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent);
typeUnicodeText, NULL, actualSize, NULL, text)) require_noerr(err, done);
break;
EventRef keyEvent; err = GetEventParameter(keyEvent, kEventParamKeyModifiers,
if (noErr != GetEventParameter(theEvent, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
kEventParamTextInputSendKeyboardEvent, require_noerr(err, done);
typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent))
break; err = GetEventParameter(keyEvent, kEventParamKeyCode,
if (noErr != GetEventParameter(keyEvent, typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym);
kEventParamKeyModifiers, require_noerr(err, done);
typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers))
break; err = GetEventParameter(keyEvent, kEventParamKeyMacCharCodes,
if (noErr != GetEventParameter(keyEvent, typeChar, NULL, sizeof(char), NULL, &charcode);
kEventParamKeyCode, require_noerr(err, done);
typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym))
break; #ifndef USE_CMD_KEY
if (noErr != GetEventParameter(keyEvent, if (modifiers & cmdKey)
kEventParamKeyMacCharCodes, goto done; /* Let system handle Cmd+... */
typeChar, NULL, sizeof(char), NULL, &charcode)) #endif
break;
key_char = charcode; key_char = charcode;
vimModifiers = EventModifiers2VimModifiers(modifiers);
if (modifiers & controlKey)
{
if ((modifiers & ~(controlKey|shiftKey)) == 0
&& (key_char == '2' || key_char == '6'))
{
/* CTRL-^ and CTRL-@ don't work in the normal way. */
if (key_char == '2')
key_char = Ctrl_AT;
else
key_char = Ctrl_HAT;
text[0] = (UniChar)key_char;
modifiers = 0;
}
}
if (modifiers & cmdKey)
#ifndef USE_CMD_KEY
break; /* Let system handle Cmd+... */
#else
{
/* Intercept CMD-. */
if (key_char == '.')
got_int = TRUE;
/* Convert the modifiers */
modifiers = EventModifiers2VimModifiers(modifiers);
/* Following code to simplify and consolidate modifiers
* taken liberally from gui_w48.c */
key_char = simplify_key(key_char, (int *)&modifiers);
/* remove SHIFT for keys that are already shifted, e.g.,
* '(' and '*' */
if (key_char < 0x100 &&
!isalpha(key_char) && isprint(key_char))
modifiers &= ~MOD_MASK_SHIFT;
/* Interpret META, include SHIFT, etc. */
key_char = extract_modifiers(key_char, (int *)&modifiers);
if (key_char == CSI)
key_char = K_CSI;
if (modifiers)
{
result[len++] = CSI;
result[len++] = KS_MODIFIER;
result[len++] = modifiers;
}
isSpecial = TRUE;
}
#endif
else
{
/* Find the special key (eg., for cursor keys) */ /* Find the special key (eg., for cursor keys) */
if (!(actualSize > sizeof(UniChar)) && if (actualSize <= sizeof(UniChar) &&
((text[0] < 0x20) || (text[0] == 0x7f))) ((text[0] < 0x20) || (text[0] == 0x7f)))
{ {
for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i) for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
@@ -2138,11 +2083,50 @@ gui_mac_doKeyEventCarbon(
key_char = TO_SPECIAL(special_keys[i].vim_code0, key_char = TO_SPECIAL(special_keys[i].vim_code0,
special_keys[i].vim_code1); special_keys[i].vim_code1);
key_char = simplify_key(key_char, key_char = simplify_key(key_char,
(int *)&modifiers); (int *)&vimModifiers);
isSpecial = TRUE; isSpecial = TRUE;
break; break;
} }
} }
/* Intercept CMD-. and CTRL-c */
if (((modifiers & controlKey) && key_char == 'c') ||
((modifiers & cmdKey) && key_char == '.'))
got_int = TRUE;
if (!isSpecial)
{
/* remove SHIFT for keys that are already shifted, e.g.,
* '(' and '*' */
if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char))
vimModifiers &= ~MOD_MASK_SHIFT;
/* remove CTRL from keys that already have it */
if (key_char < 0x20)
vimModifiers &= ~MOD_MASK_CTRL;
/* don't process unicode characters here */
if (!IS_SPECIAL(key_char))
{
/* Following code to simplify and consolidate vimModifiers
* taken liberally from gui_w48.c */
key_char = simplify_key(key_char, (int *)&vimModifiers);
/* Interpret META, include SHIFT, etc. */
key_char = extract_modifiers(key_char, (int *)&vimModifiers);
if (key_char == CSI)
key_char = K_CSI;
if (IS_SPECIAL(key_char))
isSpecial = TRUE;
}
}
if (vimModifiers)
{
result[len++] = CSI;
result[len++] = KS_MODIFIER;
result[len++] = vimModifiers;
} }
if (isSpecial && IS_SPECIAL(key_char)) if (isSpecial && IS_SPECIAL(key_char))
@@ -2155,8 +2139,6 @@ gui_mac_doKeyEventCarbon(
{ {
encLen = actualSize; encLen = actualSize;
to = mac_utf16_to_enc(text, actualSize, &encLen); to = mac_utf16_to_enc(text, actualSize, &encLen);
}
if (to) if (to)
{ {
/* This is basically add_to_input_buf_csi() */ /* This is basically add_to_input_buf_csi() */
@@ -2171,25 +2153,22 @@ gui_mac_doKeyEventCarbon(
} }
vim_free(to); vim_free(to);
} }
}
add_to_input_buf(result, len); add_to_input_buf(result, len);
e = noErr; err = noErr;
}
while (0);
done:
vim_free(text); vim_free(text);
if (e == noErr) if (err == noErr)
{ {
/* Fake event to wake up WNE (required to get /* Fake event to wake up WNE (required to get
* key repeat working */ * key repeat working */
PostEvent(keyUp, 0); PostEvent(keyUp, 0);
return noErr; return noErr;
} }
}
}
while (0);
return CallNextEventHandler(nextHandler, theEvent); return eventNotHandledErr;
} }
#else #else
void void
@@ -5748,7 +5727,8 @@ gui_mch_show_popupmenu(vimmenu_T *menu)
/* TODO: Get the text selection from Vim */ /* TODO: Get the text selection from Vim */
/* Call to Handle Popup */ /* Call to Handle Popup */
status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemNoHelp, HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem); status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemNoHelp,
HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem);
if (status == noErr) if (status == noErr)
{ {
@@ -5756,7 +5736,8 @@ gui_mch_show_popupmenu(vimmenu_T *menu)
{ {
/* Handle the menu CntxMenuID, CntxMenuItem */ /* Handle the menu CntxMenuID, CntxMenuItem */
/* The submenu can be handle directly by gui_mac_handle_menu */ /* The submenu can be handle directly by gui_mac_handle_menu */
/* But what about the current menu, is the menu changed by ContextualMenuSelect */ /* But what about the current menu, is the menu changed by
* ContextualMenuSelect */
gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem);
} }
else if (CntxMenuID == kCMShowHelpSelected) else if (CntxMenuID == kCMShowHelpSelected)

View File

@@ -666,6 +666,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
138,
/**/ /**/
137, 137,
/**/ /**/