home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.0.251 < prev    next >
Encoding:
Internet Message Format  |  2002-02-20  |  4.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.251 (extra)
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.0.251 (extra)
  11. Problem:    Macintosh: menu shortcuts are not very clear.
  12. Solution:   Show the shortcut with the Mac clover symbol. (raindog)
  13. Files:        src/gui_mac.c
  14.  
  15.  
  16. *** ../vim60.250/src/gui_mac.c    Thu Feb 21 19:20:14 2002
  17. --- src/gui_mac.c    Thu Feb 21 19:23:43 2002
  18. ***************
  19. *** 3756,3761 ****
  20. --- 3756,3762 ----
  21.   {
  22.       char_u    *name;
  23.       vimmenu_T    *parent = menu->parent;
  24. +     int        menu_inserted;
  25.   
  26.       /* Cannot add item, if the menu have not been created */
  27.       if (parent->submenu_id == 0)
  28. ***************
  29. *** 3777,3786 ****
  30.       idx += gui.MacOSHelpItems;
  31.   #endif
  32.   
  33.       /* Call InsertMenuItem followed by SetMenuItemText
  34.        * to avoid special character recognition by InsertMenuItem
  35.        */
  36. !     InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */
  37.       SetMenuItemText(parent->submenu_handle, idx+1, name);
  38.   
  39.   #if 0
  40. --- 3778,3856 ----
  41.       idx += gui.MacOSHelpItems;
  42.   #endif
  43.   
  44. +     menu_inserted = 0;
  45. +     if (menu->actext)
  46. +     {
  47. +     /* If the accelerator text for the menu item looks like it describes
  48. +      * a command key (e.g., "<D-S-t>" or "<C-7>"), display it as the
  49. +      * item's command equivalent.
  50. +      */
  51. +     int        key = 0;
  52. +     int        modifiers = 0;
  53. +     char_u        *p_actext;
  54. +     p_actext = menu->actext;
  55. +     key = find_special_key(&p_actext, &modifiers, /*keycode=*/0);
  56. +     if (*p_actext != 0)
  57. +         key = 0; /* error: trailing text */
  58. +     /* find_special_key() returns a keycode with as many of the
  59. +      * specified modifiers as appropriate already applied (e.g., for
  60. +      * "<D-C-x>" it returns Ctrl-X as the keycode and MOD_MASK_CMD
  61. +      * as the only modifier).  Since we want to display all of the
  62. +      * modifiers, we need to convert the keycode back to a printable
  63. +      * character plus modifiers.
  64. +      * TODO: Write an alternative find_special_key() that doesn't
  65. +      * apply modifiers.
  66. +      */
  67. +     if (key > 0 && key < 32)
  68. +     {
  69. +         /* Convert a control key to an uppercase letter.  Note that
  70. +          * by this point it is no longer possible to distinguish
  71. +          * between, e.g., Ctrl-S and Ctrl-Shift-S.
  72. +          */
  73. +         modifiers |= MOD_MASK_CTRL;
  74. +         key += '@';
  75. +     }
  76. +     /* If the keycode is an uppercase letter, set the Shift modifier.
  77. +      * If it is a lowercase letter, don't set the modifier, but convert
  78. +      * the letter to uppercase for display in the menu.
  79. +      */
  80. +     else if (key >= 'A' && key <= 'Z')
  81. +         modifiers |= MOD_MASK_SHIFT;
  82. +     else if (key >= 'a' && key <= 'z')
  83. +         key += 'A' - 'a';
  84. +     /* Note: keycodes below 0x22 are reserved by Apple. */
  85. +     if (key >= 0x22 && vim_isprintc_strict(key))
  86. +     {
  87. +         int        valid = 1;
  88. +         char_u      mac_mods = kMenuNoModifiers;
  89. +         /* Convert Vim modifier codes to Menu Manager equivalents. */
  90. +         if (modifiers & MOD_MASK_SHIFT)
  91. +         mac_mods |= kMenuShiftModifier;
  92. +         if (modifiers & MOD_MASK_CTRL)
  93. +         mac_mods |= kMenuControlModifier;
  94. +         if (!(modifiers & MOD_MASK_CMD))
  95. +         mac_mods |= kMenuNoCommandModifier;
  96. +         if (modifiers & MOD_MASK_ALT || modifiers & MOD_MASK_MULTI_CLICK)
  97. +         valid = 0; /* TODO: will Alt someday map to Option? */
  98. +         if (valid)
  99. +         {
  100. +         char_u        item_txt[10];
  101. +         /* Insert the menu item after idx, with its command key. */
  102. +         item_txt[0] = 3; item_txt[1] = ' '; item_txt[2] = '/';
  103. +         item_txt[3] = key;
  104. +         InsertMenuItem(parent->submenu_handle, item_txt, idx);
  105. +         /* Set the modifier keys. */
  106. +         SetMenuItemModifiers(parent->submenu_handle, idx+1, mac_mods);
  107. +         menu_inserted = 1;
  108. +         }
  109. +     }
  110. +     }
  111.       /* Call InsertMenuItem followed by SetMenuItemText
  112.        * to avoid special character recognition by InsertMenuItem
  113.        */
  114. !     if (!menu_inserted)
  115. !     InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */
  116. !     /* Set the menu item name. */
  117.       SetMenuItemText(parent->submenu_handle, idx+1, name);
  118.   
  119.   #if 0
  120. *** ../vim60.250/src/version.c    Thu Feb 21 19:20:14 2002
  121. --- src/version.c    Thu Feb 21 19:24:32 2002
  122. ***************
  123. *** 608,609 ****
  124. --- 608,611 ----
  125.   {   /* Add new patch number below this line */
  126. + /**/
  127. +     251,
  128.   /**/
  129.  
  130. -- 
  131. Engineers are always delighted to share wisdom, even in areas in which they
  132. have no experience whatsoever.  Their logic provides them with inherent
  133. insight into any field of expertise.  This can be a problem when dealing with
  134. the illogical people who believe that knowledge can only be derived through
  135. experience.
  136.                 (Scott Adams - The Dilbert principle)
  137.  
  138.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  139. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  140. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  141.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  142.