• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisionbe8e2719caa6c7194ce4713206da6f1f8db694ca (tree)
Zeit2006-10-17 19:51:57
Autorvimboss
Commitervimboss

Log Message

updated for version 7.0-138

Ändern Zusammenfassung

Diff

diff -r 6e03ee418b50 -r be8e2719caa6 src/gui_mac.c
--- a/src/gui_mac.c Tue Oct 17 09:49:09 2006 +0000
+++ b/src/gui_mac.c Tue Oct 17 10:51:57 2006 +0000
@@ -2014,7 +2014,7 @@
20142014 void *data)
20152015 {
20162016 /* Multibyte-friendly key event handler */
2017- OSStatus e = -1;
2017+ OSStatus err = -1;
20182018 UInt32 actualSize;
20192019 UniChar *text;
20202020 char_u result[INLINE_KEY_BUFFER_SIZE];
@@ -2022,174 +2022,153 @@
20222022 UInt32 key_sym;
20232023 char charcode;
20242024 int key_char;
2025- UInt32 modifiers;
2025+ UInt32 modifiers, vimModifiers;
20262026 size_t encLen;
20272027 char_u *to = NULL;
20282028 Boolean isSpecial = FALSE;
20292029 int i;
2030+ EventRef keyEvent;
20302031
20312032 /* Mask the mouse (as per user setting) */
20322033 if (p_mh)
20332034 ObscureCursor();
20342035
2035- do
2036- {
2037- /* Don't use the keys when the dialog wants them. */
2038- if (dialog_busy)
2039- break;
2040-
2041- if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText,
2042- typeUnicodeText, NULL, 0, &actualSize, NULL))
2043- break;
2044-
2045- text = (UniChar *)alloc(actualSize);
2046-
2047- if (text)
2048- {
2049- do
2050- {
2051- if (noErr != GetEventParameter(theEvent,
2052- kEventParamTextInputSendText,
2053- typeUnicodeText, NULL, actualSize, NULL, text))
2054- break;
2055- EventRef keyEvent;
2056- if (noErr != GetEventParameter(theEvent,
2057- kEventParamTextInputSendKeyboardEvent,
2058- typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent))
2059- break;
2060- if (noErr != GetEventParameter(keyEvent,
2061- kEventParamKeyModifiers,
2062- typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers))
2063- break;
2064- if (noErr != GetEventParameter(keyEvent,
2065- kEventParamKeyCode,
2066- typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym))
2067- break;
2068- if (noErr != GetEventParameter(keyEvent,
2069- kEventParamKeyMacCharCodes,
2070- typeChar, NULL, sizeof(char), NULL, &charcode))
2071- break;
2072-
2073- key_char = charcode;
2074-
2075- if (modifiers & controlKey)
2076- {
2077- if ((modifiers & ~(controlKey|shiftKey)) == 0
2078- && (key_char == '2' || key_char == '6'))
2079- {
2080- /* CTRL-^ and CTRL-@ don't work in the normal way. */
2081- if (key_char == '2')
2082- key_char = Ctrl_AT;
2083- else
2084- key_char = Ctrl_HAT;
2085-
2086- text[0] = (UniChar)key_char;
2087- modifiers = 0;
2088- }
2089- }
2090-
2091- if (modifiers & cmdKey)
2036+ /* Don't use the keys when the dialog wants them. */
2037+ if (dialog_busy)
2038+ return eventNotHandledErr;
2039+
2040+ if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText,
2041+ typeUnicodeText, NULL, 0, &actualSize, NULL))
2042+ return eventNotHandledErr;
2043+
2044+ text = (UniChar *)alloc(actualSize);
2045+ if (!text)
2046+ return eventNotHandledErr;
2047+
2048+ err = GetEventParameter(theEvent, kEventParamTextInputSendText,
2049+ typeUnicodeText, NULL, actualSize, NULL, text);
2050+ require_noerr(err, done);
2051+
2052+ err = GetEventParameter(theEvent, kEventParamTextInputSendKeyboardEvent,
2053+ typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent);
2054+ require_noerr(err, done);
2055+
2056+ err = GetEventParameter(keyEvent, kEventParamKeyModifiers,
2057+ typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
2058+ require_noerr(err, done);
2059+
2060+ err = GetEventParameter(keyEvent, kEventParamKeyCode,
2061+ typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym);
2062+ require_noerr(err, done);
2063+
2064+ err = GetEventParameter(keyEvent, kEventParamKeyMacCharCodes,
2065+ typeChar, NULL, sizeof(char), NULL, &charcode);
2066+ require_noerr(err, done);
2067+
20922068 #ifndef USE_CMD_KEY
2093- break; /* Let system handle Cmd+... */
2094-#else
2095- {
2096- /* Intercept CMD-. */
2097- if (key_char == '.')
2098- got_int = TRUE;
2099-
2100- /* Convert the modifiers */
2101- modifiers = EventModifiers2VimModifiers(modifiers);
2102-
2103- /* Following code to simplify and consolidate modifiers
2104- * taken liberally from gui_w48.c */
2105-
2106- key_char = simplify_key(key_char, (int *)&modifiers);
2107-
2108- /* remove SHIFT for keys that are already shifted, e.g.,
2109- * '(' and '*' */
2110- if (key_char < 0x100 &&
2111- !isalpha(key_char) && isprint(key_char))
2112- modifiers &= ~MOD_MASK_SHIFT;
2113-
2114- /* Interpret META, include SHIFT, etc. */
2115- key_char = extract_modifiers(key_char, (int *)&modifiers);
2116- if (key_char == CSI)
2117- key_char = K_CSI;
2118-
2119- if (modifiers)
2120- {
2121- result[len++] = CSI;
2122- result[len++] = KS_MODIFIER;
2123- result[len++] = modifiers;
2124- }
2125-
2126- isSpecial = TRUE;
2127- }
2069+ if (modifiers & cmdKey)
2070+ goto done; /* Let system handle Cmd+... */
21282071 #endif
2129- else
2130- {
2131- /* Find the special key (eg., for cursor keys) */
2132- if (!(actualSize > sizeof(UniChar)) &&
2133- ((text[0] < 0x20) || (text[0] == 0x7f)))
2134- {
2135- for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
2136- if (special_keys[i].key_sym == key_sym)
2137- {
2138- key_char = TO_SPECIAL(special_keys[i].vim_code0,
2139- special_keys[i].vim_code1);
2140- key_char = simplify_key(key_char,
2141- (int *)&modifiers);
2142- isSpecial = TRUE;
2143- break;
2144- }
2145- }
2146- }
2147-
2148- if (isSpecial && IS_SPECIAL(key_char))
2149- {
2150- result[len++] = CSI;
2151- result[len++] = K_SECOND(key_char);
2152- result[len++] = K_THIRD(key_char);
2153- }
2154- else
2155- {
2156- encLen = actualSize;
2157- to = mac_utf16_to_enc(text, actualSize, &encLen);
2158- }
2159-
2160- if (to)
2161- {
2162- /* This is basically add_to_input_buf_csi() */
2163- for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i)
2164- {
2165- result[len++] = to[i];
2166- if (to[i] == CSI)
2167- {
2168- result[len++] = KS_EXTRA;
2169- result[len++] = (int)KE_CSI;
2170- }
2171- }
2172- vim_free(to);
2173- }
2174-
2175- add_to_input_buf(result, len);
2176- e = noErr;
2177- }
2178- while (0);
2179-
2180- vim_free(text);
2181- if (e == noErr)
2182- {
2183- /* Fake event to wake up WNE (required to get
2184- * key repeat working */
2185- PostEvent(keyUp, 0);
2186- return noErr;
2187- }
2188- }
2072+
2073+ key_char = charcode;
2074+ vimModifiers = EventModifiers2VimModifiers(modifiers);
2075+
2076+ /* Find the special key (eg., for cursor keys) */
2077+ if (actualSize <= sizeof(UniChar) &&
2078+ ((text[0] < 0x20) || (text[0] == 0x7f)))
2079+ {
2080+ for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
2081+ if (special_keys[i].key_sym == key_sym)
2082+ {
2083+ key_char = TO_SPECIAL(special_keys[i].vim_code0,
2084+ special_keys[i].vim_code1);
2085+ key_char = simplify_key(key_char,
2086+ (int *)&vimModifiers);
2087+ isSpecial = TRUE;
2088+ break;
2089+ }
21892090 }
2190- while (0);
2191-
2192- return CallNextEventHandler(nextHandler, theEvent);
2091+
2092+ /* Intercept CMD-. and CTRL-c */
2093+ if (((modifiers & controlKey) && key_char == 'c') ||
2094+ ((modifiers & cmdKey) && key_char == '.'))
2095+ got_int = TRUE;
2096+
2097+ if (!isSpecial)
2098+ {
2099+ /* remove SHIFT for keys that are already shifted, e.g.,
2100+ * '(' and '*' */
2101+ if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char))
2102+ vimModifiers &= ~MOD_MASK_SHIFT;
2103+
2104+ /* remove CTRL from keys that already have it */
2105+ if (key_char < 0x20)
2106+ vimModifiers &= ~MOD_MASK_CTRL;
2107+
2108+ /* don't process unicode characters here */
2109+ if (!IS_SPECIAL(key_char))
2110+ {
2111+ /* Following code to simplify and consolidate vimModifiers
2112+ * taken liberally from gui_w48.c */
2113+ key_char = simplify_key(key_char, (int *)&vimModifiers);
2114+
2115+ /* Interpret META, include SHIFT, etc. */
2116+ key_char = extract_modifiers(key_char, (int *)&vimModifiers);
2117+ if (key_char == CSI)
2118+ key_char = K_CSI;
2119+
2120+ if (IS_SPECIAL(key_char))
2121+ isSpecial = TRUE;
2122+ }
2123+ }
2124+
2125+ if (vimModifiers)
2126+ {
2127+ result[len++] = CSI;
2128+ result[len++] = KS_MODIFIER;
2129+ result[len++] = vimModifiers;
2130+ }
2131+
2132+ if (isSpecial && IS_SPECIAL(key_char))
2133+ {
2134+ result[len++] = CSI;
2135+ result[len++] = K_SECOND(key_char);
2136+ result[len++] = K_THIRD(key_char);
2137+ }
2138+ else
2139+ {
2140+ encLen = actualSize;
2141+ to = mac_utf16_to_enc(text, actualSize, &encLen);
2142+ if (to)
2143+ {
2144+ /* This is basically add_to_input_buf_csi() */
2145+ for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i)
2146+ {
2147+ result[len++] = to[i];
2148+ if (to[i] == CSI)
2149+ {
2150+ result[len++] = KS_EXTRA;
2151+ result[len++] = (int)KE_CSI;
2152+ }
2153+ }
2154+ vim_free(to);
2155+ }
2156+ }
2157+
2158+ add_to_input_buf(result, len);
2159+ err = noErr;
2160+
2161+done:
2162+ vim_free(text);
2163+ if (err == noErr)
2164+ {
2165+ /* Fake event to wake up WNE (required to get
2166+ * key repeat working */
2167+ PostEvent(keyUp, 0);
2168+ return noErr;
2169+ }
2170+
2171+ return eventNotHandledErr;
21932172 }
21942173 #else
21952174 void
@@ -5748,7 +5727,8 @@
57485727 /* TODO: Get the text selection from Vim */
57495728
57505729 /* Call to Handle Popup */
5751- status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemNoHelp, HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem);
5730+ status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemNoHelp,
5731+ HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem);
57525732
57535733 if (status == noErr)
57545734 {
@@ -5756,7 +5736,8 @@
57565736 {
57575737 /* Handle the menu CntxMenuID, CntxMenuItem */
57585738 /* The submenu can be handle directly by gui_mac_handle_menu */
5759- /* But what about the current menu, is the menu changed by ContextualMenuSelect */
5739+ /* But what about the current menu, is the menu changed by
5740+ * ContextualMenuSelect */
57605741 gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem);
57615742 }
57625743 else if (CntxMenuID == kCMShowHelpSelected)
diff -r 6e03ee418b50 -r be8e2719caa6 src/version.c
--- a/src/version.c Tue Oct 17 09:49:09 2006 +0000
+++ b/src/version.c Tue Oct 17 10:51:57 2006 +0000
@@ -667,6 +667,8 @@
667667 static int included_patches[] =
668668 { /* Add new patch number below this line */
669669 /**/
670+ 138,
671+/**/
670672 137,
671673 /**/
672674 136,
Show on old repository browser