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.2.267 < prev    next >
Encoding:
Internet Message Format  |  2004-02-16  |  10.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.267 (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.2.267 (extra)
  11. Problem:    Win32: "&&" in a tearoff menu is not shown. (Luc Hermitte)
  12. Solution:   Use the "name" item from the menu instead of the "dname" item.
  13. Files:        src/gui_w32.c, src/menu.c
  14.  
  15.  
  16. *** ../vim-6.2.266/src/gui_w32.c    Sun Jan 25 20:24:03 2004
  17. --- src/gui_w32.c    Mon Feb 16 12:19:06 2004
  18. ***************
  19. *** 2965,2971 ****
  20.       HFONT    font, oldFont;
  21.       int        col, spaceWidth, len;
  22.       int        columnWidths[2];
  23. !     char_u    *label, *text, *end, *acEnd = NULL;
  24.       int        padding0, padding1, padding2 = 0;
  25.       int        sepPadding=0;
  26.   #ifdef USE_SYSMENU_FONT
  27. --- 2965,2973 ----
  28.       HFONT    font, oldFont;
  29.       int        col, spaceWidth, len;
  30.       int        columnWidths[2];
  31. !     char_u    *label, *text;
  32. !     int        acLen;
  33. !     int        nameLen;
  34.       int        padding0, padding1, padding2 = 0;
  35.       int        sepPadding=0;
  36.   #ifdef USE_SYSMENU_FONT
  37. ***************
  38. *** 2974,2984 ****
  39.   #endif
  40.   
  41.       /*
  42. !      * If this menu is already torn off, then don't
  43. !      * tear it off again, but move the existing tearoff
  44. !      * to the mouse position.
  45.        */
  46.       if (IsWindow(menu->tearoff_handle))
  47.       {
  48.       POINT mp;
  49. --- 2976,2983 ----
  50.   #endif
  51.   
  52.       /*
  53. !      * If this menu is already torn off, move it to the mouse position.
  54.        */
  55.       if (IsWindow(menu->tearoff_handle))
  56.       {
  57.       POINT mp;
  58. ***************
  59. *** 2991,3003 ****
  60.       }
  61.   
  62.       /*
  63. !      * Otherwise, create a new tearoff
  64.        */
  65.       if (*title == MNU_HIDDEN_CHAR)
  66.       title++;
  67.   
  68. !     /* Allocate some memory to play with.  It's made bigger when needed. */
  69.       template_len = DLG_ALLOC_SIZE;
  70.       pdlgtemplate = p = (WORD *)LocalAlloc(LPTR, template_len);
  71.       if (p == NULL)
  72. --- 2990,3002 ----
  73.       }
  74.   
  75.       /*
  76. !      * Create a new tearoff.
  77.        */
  78.       if (*title == MNU_HIDDEN_CHAR)
  79.       title++;
  80.   
  81. !     /* Allocate memory to store the dialog template.  It's made bigger when
  82. !      * needed. */
  83.       template_len = DLG_ALLOC_SIZE;
  84.       pdlgtemplate = p = (WORD *)LocalAlloc(LPTR, template_len);
  85.       if (p == NULL)
  86. ***************
  87. *** 3019,3051 ****
  88.       oldFont = SelectFont(hdc, font);
  89.       else
  90.       oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT));
  91. !     /*
  92. !      * Calculate width of a single space.  Used for padding columns to the
  93. !      * right width.
  94. !      */
  95.       spaceWidth = GetTextWidth(hdc, " ", 1);
  96.   
  97.       submenuWidth = 0;
  98. -     /* Figure out widths for each column. */
  99.       for (col = 0; col < 2; col++)
  100.       {
  101.       columnWidths[col] = 0;
  102.       for (pmenu = menu->children; pmenu != NULL; pmenu = pmenu->next)
  103.       {
  104.           text = (col == 0) ? pmenu->dname : pmenu->actext;
  105. -         if (pmenu->children != NULL)
  106. -         submenuWidth = TEAROFF_COLUMN_PADDING * spaceWidth;
  107.           if (text != NULL && *text != NUL)
  108.           {
  109. !         end = text + strlen(text);
  110. !         textWidth = GetTextWidth(hdc, text, (int)(end - text));
  111.           if (textWidth > columnWidths[col])
  112.               columnWidths[col] = textWidth;
  113.           }
  114.       }
  115.       }
  116.       if (columnWidths[1] == 0)
  117.       {
  118.       if (submenuWidth != 0)
  119.           columnWidths[0] += submenuWidth;
  120.       else
  121. --- 3018,3051 ----
  122.       oldFont = SelectFont(hdc, font);
  123.       else
  124.       oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT));
  125. !     /* Calculate width of a single space.  Used for padding columns to the
  126. !      * right width. */
  127.       spaceWidth = GetTextWidth(hdc, " ", 1);
  128.   
  129. +     /* Figure out max width of the text column, the accelerator column and the
  130. +      * optional submenu column. */
  131.       submenuWidth = 0;
  132.       for (col = 0; col < 2; col++)
  133.       {
  134.       columnWidths[col] = 0;
  135.       for (pmenu = menu->children; pmenu != NULL; pmenu = pmenu->next)
  136.       {
  137. +         /* Use "dname" here to compute the width of the visible text. */
  138.           text = (col == 0) ? pmenu->dname : pmenu->actext;
  139.           if (text != NULL && *text != NUL)
  140.           {
  141. !         textWidth = GetTextWidth(hdc, text, (int)STRLEN(text));
  142.           if (textWidth > columnWidths[col])
  143.               columnWidths[col] = textWidth;
  144.           }
  145. +         if (pmenu->children != NULL)
  146. +         submenuWidth = TEAROFF_COLUMN_PADDING * spaceWidth;
  147.       }
  148.       }
  149.       if (columnWidths[1] == 0)
  150.       {
  151. +     /* no accelerators */
  152.       if (submenuWidth != 0)
  153.           columnWidths[0] += submenuWidth;
  154.       else
  155. ***************
  156. *** 3053,3071 ****
  157.       }
  158.       else
  159.       {
  160.       columnWidths[0] += TEAROFF_COLUMN_PADDING * spaceWidth;
  161.       columnWidths[1] += submenuWidth;
  162.       }
  163.       /*
  164. !      * Now find the width of our 'menu'.
  165.        */
  166. !     textWidth = 0;
  167. !     for (col = 0; col < 2; col++)
  168. !     textWidth += columnWidths[col];
  169.       if (submenuWidth != 0)
  170.       {
  171.       submenuWidth = GetTextWidth(hdc, TEAROFF_SUBMENU_LABEL,
  172. !                   (int)STRLEN(TEAROFF_SUBMENU_LABEL));
  173.       textWidth += submenuWidth;
  174.       }
  175.       dlgwidth = GetTextWidth(hdc, title, (int)STRLEN(title));
  176. --- 3053,3071 ----
  177.       }
  178.       else
  179.       {
  180. +     /* there is an accelerator column */
  181.       columnWidths[0] += TEAROFF_COLUMN_PADDING * spaceWidth;
  182.       columnWidths[1] += submenuWidth;
  183.       }
  184.       /*
  185. !      * Now find the total width of our 'menu'.
  186.        */
  187. !     textWidth = columnWidths[0] + columnWidths[1];
  188.       if (submenuWidth != 0)
  189.       {
  190.       submenuWidth = GetTextWidth(hdc, TEAROFF_SUBMENU_LABEL,
  191. !                       (int)STRLEN(TEAROFF_SUBMENU_LABEL));
  192.       textWidth += submenuWidth;
  193.       }
  194.       dlgwidth = GetTextWidth(hdc, title, (int)STRLEN(title));
  195. ***************
  196. *** 3105,3113 ****
  197.       *p++ = 0;        // Class
  198.   
  199.       /* copy the title of the dialog */
  200. !     nchar = nCopyAnsiToWideChar(p, ((*title) ?
  201. !                     (LPSTR)title :
  202. !                     (LPSTR)("Vim "VIM_VERSION_MEDIUM)));
  203.       p += nchar;
  204.   
  205.       if (s_usenewlook)
  206. --- 3105,3113 ----
  207.       *p++ = 0;        // Class
  208.   
  209.       /* copy the title of the dialog */
  210. !     nchar = nCopyAnsiToWideChar(p, ((*title)
  211. !                     ? (LPSTR)title
  212. !                     : (LPSTR)("Vim "VIM_VERSION_MEDIUM)));
  213.       p += nchar;
  214.   
  215.       if (s_usenewlook)
  216. ***************
  217. *** 3130,3141 ****
  218.       p += nchar;
  219.       }
  220.   
  221. !     /* Don't include tearbar in tearoff menu */
  222.       if (STRCMP(menu->children->name, TEAR_STRING) == 0)
  223.       menu = menu->children->next;
  224.       else
  225.       menu = menu->children;
  226.       for ( ; menu != NULL; menu = menu->next)
  227.       {
  228.       if (menu->modes == 0)    /* this menu has just been deleted */
  229. --- 3130,3143 ----
  230.       p += nchar;
  231.       }
  232.   
  233. !     /*
  234. !      * Loop over all the items in the menu.
  235. !      * But skip over the tearbar.
  236. !      */
  237.       if (STRCMP(menu->children->name, TEAR_STRING) == 0)
  238.       menu = menu->children->next;
  239.       else
  240.       menu = menu->children;
  241.       for ( ; menu != NULL; menu = menu->next)
  242.       {
  243.       if (menu->modes == 0)    /* this menu has just been deleted */
  244. ***************
  245. *** 3166,3188 ****
  246.           }
  247.       }
  248.   
  249. !     /* Figure out length of this menu label */
  250. !     len = (int)STRLEN(menu->dname);
  251. !     end = menu->dname + STRLEN(menu->dname);
  252.       padding0 = (columnWidths[0] - GetTextWidth(hdc, menu->dname,
  253. !             (int)(end - menu->dname))) / spaceWidth;
  254.       len += padding0;
  255.       if (menu->actext != NULL)
  256.       {
  257. !         len += (int)STRLEN(menu->actext);
  258. !         acEnd = menu->actext + STRLEN(menu->actext);
  259. !         textWidth = GetTextWidth(hdc, menu->actext, (int)(acEnd - menu->actext));
  260.       }
  261.       else
  262.           textWidth = 0;
  263.       padding1 = (columnWidths[1] - textWidth) / spaceWidth;
  264.       len += padding1;
  265.       if (menu->children == NULL)
  266.       {
  267.           padding2 = submenuWidth / spaceWidth;
  268. --- 3168,3192 ----
  269.           }
  270.       }
  271.   
  272. !     /* Figure out minimal length of this menu label.  Use "name" for the
  273. !      * actual text, "dname" for estimating the displayed size.  "name"
  274. !      * has "&a" for mnemonic and includes the accelerator. */
  275. !     len = nameLen = (int)STRLEN(menu->name);
  276.       padding0 = (columnWidths[0] - GetTextWidth(hdc, menu->dname,
  277. !                       (int)STRLEN(menu->dname))) / spaceWidth;
  278.       len += padding0;
  279.       if (menu->actext != NULL)
  280.       {
  281. !         acLen = (int)STRLEN(menu->actext);
  282. !         len += acLen;
  283. !         textWidth = GetTextWidth(hdc, menu->actext, acLen);
  284.       }
  285.       else
  286.           textWidth = 0;
  287.       padding1 = (columnWidths[1] - textWidth) / spaceWidth;
  288.       len += padding1;
  289.       if (menu->children == NULL)
  290.       {
  291.           padding2 = submenuWidth / spaceWidth;
  292. ***************
  293. *** 3199,3212 ****
  294.       text = label = alloc((unsigned)len + 1);
  295.       if (label == NULL)
  296.           break;
  297. !     STRNCPY(text, menu->dname, end - menu->dname);
  298. !     text += end - menu->dname;
  299.       while (padding0-- > 0)
  300.           *text++ = ' ';
  301.       if (menu->actext != NULL)
  302.       {
  303. !         STRNCPY(text, menu->actext, acEnd - menu->actext);
  304. !         text += acEnd - menu->actext;
  305.       }
  306.       while (padding1-- > 0)
  307.           *text++ = ' ';
  308. --- 3203,3219 ----
  309.       text = label = alloc((unsigned)len + 1);
  310.       if (label == NULL)
  311.           break;
  312. !     STRNCPY(text, menu->name, nameLen);
  313. !     text = vim_strchr(text, TAB);        /* stop at TAB before actext */
  314. !     if (text == NULL)
  315. !         text = label + nameLen;        /* no actext, use whole name */
  316.       while (padding0-- > 0)
  317.           *text++ = ' ';
  318.       if (menu->actext != NULL)
  319.       {
  320. !         STRNCPY(text, menu->actext, acLen);
  321. !         text += acLen;
  322.       }
  323.       while (padding1-- > 0)
  324.           *text++ = ' ';
  325. ***************
  326. *** 3221,3227 ****
  327.           *text++ = ' ';
  328.       }
  329.       *text = NUL;
  330. -     *end = NUL;
  331.   
  332.       /*
  333.        * BS_LEFT will just be ignored on Win32s/NT3.5x - on
  334. --- 3228,3233 ----
  335. *** ../vim-6.2.266/src/menu.c    Sun Feb 15 13:33:50 2004
  336. --- src/menu.c    Sun Feb 15 22:06:06 2004
  337. ***************
  338. *** 1596,1607 ****
  339.       }
  340.       else
  341.       text = vim_strsave(str);
  342. !     if (text != NULL)
  343.       {
  344. !     p = vim_strchr(text, '&');
  345.       if (p != NULL)
  346.       {
  347. !         if (mnemonic != NULL)
  348.   #if !defined(__MVS__) || defined(MOTIF390_MNEMONIC_FIXED)
  349.           *mnemonic = p[1];
  350.   #else
  351. --- 1596,1611 ----
  352.       }
  353.       else
  354.       text = vim_strsave(str);
  355. !     /* Find mnemonic characters "&a" and reduce "&&" to "&". */
  356. !     for (p = text; p != NULL; )
  357.       {
  358. !     p = vim_strchr(p, '&');
  359.       if (p != NULL)
  360.       {
  361. !         if (p[1] == NUL)        /* trailing "&" */
  362. !         break;
  363. !         if (mnemonic != NULL && p[1] != '&')
  364.   #if !defined(__MVS__) || defined(MOTIF390_MNEMONIC_FIXED)
  365.           *mnemonic = p[1];
  366.   #else
  367. ***************
  368. *** 1618,1623 ****
  369. --- 1622,1628 ----
  370.           }
  371.   #endif
  372.           mch_memmove(p, p + 1, STRLEN(p));
  373. +         p = p + 1;
  374.       }
  375.       }
  376.       return text;
  377. *** ../vim-6.2.266/src/version.c    Tue Feb 17 20:44:14 2004
  378. --- src/version.c    Tue Feb 17 21:01:21 2004
  379. ***************
  380. *** 639,640 ****
  381. --- 639,642 ----
  382.   {   /* Add new patch number below this line */
  383. + /**/
  384. +     267,
  385.   /**/
  386.  
  387. -- 
  388. hundred-and-one symptoms of being an internet addict:
  389. 170. You introduce your wife as "my_lady@home.wife" and refer to your
  390.      children as "forked processes."
  391.  
  392.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  393. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  394. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  395.  \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///
  396.