comparison src/menu.c @ 15868:7fad90423bd2 v8.1.0941

patch 8.1.0941: macros for MS-Windows are inconsistent commit https://github.com/vim/vim/commit/4f97475d326c2773a78561fb874e4f23c25cbcd9 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 17 17:44:42 2019 +0100 patch 8.1.0941: macros for MS-Windows are inconsistent Problem: Macros for MS-Windows are inconsistent, using "32", "3264 and others. Solution: Use MSWIN for all MS-Windows builds. Use FEAT_GUI_MSWIN for the GUI build. (Hirohito Higashi, closes #3932)
author Bram Moolenaar <Bram@vim.org>
date Sun, 17 Feb 2019 17:45:08 +0100
parents 6f1c7e9a6393
children cd5c83115ec6
comparison
equal deleted inserted replaced
15867:4a3823e692d3 15868:7fad90423bd2
16 16
17 #if defined(FEAT_MENU) || defined(PROTO) 17 #if defined(FEAT_MENU) || defined(PROTO)
18 18
19 #define MENUDEPTH 10 /* maximum depth of menus */ 19 #define MENUDEPTH 10 /* maximum depth of menus */
20 20
21 #ifdef FEAT_GUI_W32 21 #ifdef FEAT_GUI_MSWIN
22 static int add_menu_path(char_u *, vimmenu_T *, int *, char_u *, int); 22 static int add_menu_path(char_u *, vimmenu_T *, int *, char_u *, int);
23 #else 23 #else
24 static int add_menu_path(char_u *, vimmenu_T *, int *, char_u *); 24 static int add_menu_path(char_u *, vimmenu_T *, int *, char_u *);
25 #endif 25 #endif
26 static int menu_nable_recurse(vimmenu_T *menu, char_u *name, int modes, int enable); 26 static int menu_nable_recurse(vimmenu_T *menu, char_u *name, int modes, int enable);
33 static int menu_namecmp(char_u *name, char_u *mname); 33 static int menu_namecmp(char_u *name, char_u *mname);
34 static int get_menu_cmd_modes(char_u *, int, int *, int *); 34 static int get_menu_cmd_modes(char_u *, int, int *, int *);
35 static char_u *popup_mode_name(char_u *name, int idx); 35 static char_u *popup_mode_name(char_u *name, int idx);
36 static char_u *menu_text(char_u *text, int *mnemonic, char_u **actext); 36 static char_u *menu_text(char_u *text, int *mnemonic, char_u **actext);
37 37
38 #if defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF) 38 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)
39 static void gui_create_tearoffs_recurse(vimmenu_T *menu, const char_u *pname, int *pri_tab, int pri_idx); 39 static void gui_create_tearoffs_recurse(vimmenu_T *menu, const char_u *pname, int *pri_tab, int pri_idx);
40 static void gui_add_tearoff(char_u *tearpath, int *pri_tab, int pri_idx); 40 static void gui_add_tearoff(char_u *tearpath, int *pri_tab, int pri_idx);
41 static void gui_destroy_tearoffs_recurse(vimmenu_T *menu); 41 static void gui_destroy_tearoffs_recurse(vimmenu_T *menu);
42 static int s_tearoffs = FALSE; 42 static int s_tearoffs = FALSE;
43 #endif 43 #endif
44 44
45 static int menu_is_hidden(char_u *name); 45 static int menu_is_hidden(char_u *name);
46 #if defined(FEAT_CMDL_COMPL) || (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)) 46 #if defined(FEAT_CMDL_COMPL) || (defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF))
47 static int menu_is_tearoff(char_u *name); 47 static int menu_is_tearoff(char_u *name);
48 #endif 48 #endif
49 49
50 #if defined(FEAT_MULTI_LANG) || defined(FEAT_TOOLBAR) 50 #if defined(FEAT_MULTI_LANG) || defined(FEAT_TOOLBAR)
51 static char_u *menu_skip_part(char_u *p); 51 static char_u *menu_skip_part(char_u *p);
120 char_u *arg; 120 char_u *arg;
121 char_u *p; 121 char_u *p;
122 int i; 122 int i;
123 #if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK) 123 #if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK)
124 int old_menu_height; 124 int old_menu_height;
125 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) 125 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
126 int old_toolbar_height; 126 int old_toolbar_height;
127 # endif 127 # endif
128 #endif 128 #endif
129 int pri_tab[MENUDEPTH + 1]; 129 int pri_tab[MENUDEPTH + 1];
130 int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu 130 int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu
293 emsg(_(e_trailing)); 293 emsg(_(e_trailing));
294 goto theend; 294 goto theend;
295 } 295 }
296 #if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON)) 296 #if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON))
297 old_menu_height = gui.menu_height; 297 old_menu_height = gui.menu_height;
298 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) 298 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
299 old_toolbar_height = gui.toolbar_height; 299 old_toolbar_height = gui.toolbar_height;
300 # endif 300 # endif
301 #endif 301 #endif
302 302
303 root_menu_ptr = get_root_menu(menu_path); 303 root_menu_ptr = get_root_menu(menu_path);
379 menuarg.iconfile = icon; 379 menuarg.iconfile = icon;
380 #endif 380 #endif
381 menuarg.noremap[0] = noremap; 381 menuarg.noremap[0] = noremap;
382 menuarg.silent[0] = silent; 382 menuarg.silent[0] = silent;
383 add_menu_path(menu_path, &menuarg, pri_tab, map_to 383 add_menu_path(menu_path, &menuarg, pri_tab, map_to
384 #ifdef FEAT_GUI_W32 384 #ifdef FEAT_GUI_MSWIN
385 , TRUE 385 , TRUE
386 #endif 386 #endif
387 ); 387 );
388 388
389 /* 389 /*
403 menuarg.iconfile = NULL; 403 menuarg.iconfile = NULL;
404 menuarg.iconidx = -1; 404 menuarg.iconidx = -1;
405 menuarg.icon_builtin = FALSE; 405 menuarg.icon_builtin = FALSE;
406 #endif 406 #endif
407 add_menu_path(p, &menuarg, pri_tab, map_to 407 add_menu_path(p, &menuarg, pri_tab, map_to
408 #ifdef FEAT_GUI_W32 408 #ifdef FEAT_GUI_MSWIN
409 , TRUE 409 , TRUE
410 #endif 410 #endif
411 ); 411 );
412 vim_free(p); 412 vim_free(p);
413 } 413 }
419 419
420 #if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK)) 420 #if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK))
421 /* If the menubar height changed, resize the window */ 421 /* If the menubar height changed, resize the window */
422 if (gui.in_use 422 if (gui.in_use
423 && (gui.menu_height != old_menu_height 423 && (gui.menu_height != old_menu_height
424 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) 424 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
425 || gui.toolbar_height != old_toolbar_height 425 || gui.toolbar_height != old_toolbar_height
426 # endif 426 # endif
427 )) 427 ))
428 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); 428 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
429 #endif 429 #endif
453 char_u *menu_path, 453 char_u *menu_path,
454 vimmenu_T *menuarg, /* passes modes, iconfile, iconidx, 454 vimmenu_T *menuarg, /* passes modes, iconfile, iconidx,
455 icon_builtin, silent[0], noremap[0] */ 455 icon_builtin, silent[0], noremap[0] */
456 int *pri_tab, 456 int *pri_tab,
457 char_u *call_data 457 char_u *call_data
458 #ifdef FEAT_GUI_W32 458 #ifdef FEAT_GUI_MSWIN
459 , int addtearoff /* may add tearoff item */ 459 , int addtearoff /* may add tearoff item */
460 #endif 460 #endif
461 ) 461 )
462 { 462 {
463 char_u *path_name; 463 char_u *path_name;
535 if (!sys_menu) 535 if (!sys_menu)
536 emsg(_("E330: Menu path must not lead to a sub-menu")); 536 emsg(_("E330: Menu path must not lead to a sub-menu"));
537 goto erret; 537 goto erret;
538 } 538 }
539 if (*next_name != NUL && menu->children == NULL 539 if (*next_name != NUL && menu->children == NULL
540 #ifdef FEAT_GUI_W32 540 #ifdef FEAT_GUI_MSWIN
541 && addtearoff 541 && addtearoff
542 #endif 542 #endif
543 ) 543 )
544 { 544 {
545 if (!sys_menu) 545 if (!sys_menu)
628 menu->iconidx = menuarg->iconidx; 628 menu->iconidx = menuarg->iconidx;
629 menu->icon_builtin = menuarg->icon_builtin; 629 menu->icon_builtin = menuarg->icon_builtin;
630 if (*next_name == NUL && menuarg->iconfile != NULL) 630 if (*next_name == NUL && menuarg->iconfile != NULL)
631 menu->iconfile = vim_strsave(menuarg->iconfile); 631 menu->iconfile = vim_strsave(menuarg->iconfile);
632 #endif 632 #endif
633 #if defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF) 633 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)
634 /* the tearoff item must be present in the modes of each item. */ 634 /* the tearoff item must be present in the modes of each item. */
635 if (parent != NULL && menu_is_tearoff(parent->children->dname)) 635 if (parent != NULL && menu_is_tearoff(parent->children->dname))
636 parent->children->modes |= modes; 636 parent->children->modes |= modes;
637 #endif 637 #endif
638 } 638 }
643 /* 643 /*
644 * If this menu option was previously only available in other 644 * If this menu option was previously only available in other
645 * modes, then make sure it's available for this one now 645 * modes, then make sure it's available for this one now
646 * Also enable a menu when it's created or changed. 646 * Also enable a menu when it's created or changed.
647 */ 647 */
648 #ifdef FEAT_GUI_W32 648 #ifdef FEAT_GUI_MSWIN
649 /* If adding a tearbar (addtearoff == FALSE) don't update modes */ 649 /* If adding a tearbar (addtearoff == FALSE) don't update modes */
650 if (addtearoff) 650 if (addtearoff)
651 #endif 651 #endif
652 { 652 {
653 menu->modes |= modes; 653 menu->modes |= modes;
678 /* Sub-menu (not at end of path yet) */ 678 /* Sub-menu (not at end of path yet) */
679 gui_mch_add_menu(menu, new_idx); 679 gui_mch_add_menu(menu, new_idx);
680 } 680 }
681 } 681 }
682 682
683 # if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF) 683 # if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
684 /* When adding a new submenu, may add a tearoff item */ 684 /* When adding a new submenu, may add a tearoff item */
685 if ( addtearoff 685 if ( addtearoff
686 && *next_name 686 && *next_name
687 && vim_strchr(p_go, GO_TEAROFF) != NULL 687 && vim_strchr(p_go, GO_TEAROFF) != NULL
688 && menu_is_menubar(name)) 688 && menu_is_menubar(name))
756 * Don't do this if adding a tearbar (addtearoff == FALSE). 756 * Don't do this if adding a tearbar (addtearoff == FALSE).
757 * Don't do this for "<Nop>". */ 757 * Don't do this for "<Nop>". */
758 c = 0; 758 c = 0;
759 d = 0; 759 d = 0;
760 if (amenu && call_data != NULL && *call_data != NUL 760 if (amenu && call_data != NULL && *call_data != NUL
761 #ifdef FEAT_GUI_W32 761 #ifdef FEAT_GUI_MSWIN
762 && addtearoff 762 && addtearoff
763 #endif 763 #endif
764 ) 764 )
765 { 765 {
766 switch (1 << i) 766 switch (1 << i)
806 menu->strings[i] = p; 806 menu->strings[i] = p;
807 menu->noremap[i] = menuarg->noremap[0]; 807 menu->noremap[i] = menuarg->noremap[0];
808 menu->silent[i] = menuarg->silent[0]; 808 menu->silent[i] = menuarg->silent[0];
809 } 809 }
810 } 810 }
811 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) \ 811 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \
812 && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK)) 812 && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK))
813 /* Need to update the menu tip. */ 813 /* Need to update the menu tip. */
814 if (modes & MENU_TIP_MODE) 814 if (modes & MENU_TIP_MODE)
815 gui_mch_menu_set_tip(menu); 815 gui_mch_menu_set_tip(menu);
816 #endif 816 #endif
936 emsg(_(e_notsubmenu)); 936 emsg(_(e_notsubmenu));
937 return FAIL; 937 return FAIL;
938 } 938 }
939 if ((menu->modes & modes) != 0x0) 939 if ((menu->modes & modes) != 0x0)
940 { 940 {
941 #if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF) 941 #if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
942 /* 942 /*
943 * If we are removing all entries for this menu,MENU_ALL_MODES, 943 * If we are removing all entries for this menu,MENU_ALL_MODES,
944 * Then kill any tearoff before we start 944 * Then kill any tearoff before we start
945 */ 945 */
946 if (*p == NUL && modes == MENU_ALL_MODES) 946 if (*p == NUL && modes == MENU_ALL_MODES)
990 } 990 }
991 991
992 992
993 /* Recalculate modes for menu based on the new updated children */ 993 /* Recalculate modes for menu based on the new updated children */
994 menu->modes &= ~modes; 994 menu->modes &= ~modes;
995 #if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF) 995 #if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
996 if ((s_tearoffs) && (menu->children != NULL)) /* there's a tear bar.. */ 996 if ((s_tearoffs) && (menu->children != NULL)) /* there's a tear bar.. */
997 child = menu->children->next; /* don't count tearoff bar */ 997 child = menu->children->next; /* don't count tearoff bar */
998 else 998 else
999 #endif 999 #endif
1000 child = menu->children; 1000 child = menu->children;
1001 for ( ; child != NULL; child = child->next) 1001 for ( ; child != NULL; child = child->next)
1002 menu->modes |= child->modes; 1002 menu->modes |= child->modes;
1003 if (modes & MENU_TIP_MODE) 1003 if (modes & MENU_TIP_MODE)
1004 { 1004 {
1005 free_menu_string(menu, MENU_INDEX_TIP); 1005 free_menu_string(menu, MENU_INDEX_TIP);
1006 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) \ 1006 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \
1007 && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK)) 1007 && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK))
1008 /* Need to update the menu tip. */ 1008 /* Need to update the menu tip. */
1009 if (gui.in_use) 1009 if (gui.in_use)
1010 gui_mch_menu_set_tip(menu); 1010 gui_mch_menu_set_tip(menu);
1011 #endif 1011 #endif
1012 } 1012 }
1013 if ((menu->modes & MENU_ALL_MODES) == 0) 1013 if ((menu->modes & MENU_ALL_MODES) == 0)
1014 { 1014 {
1015 /* The menu item is no longer valid in ANY mode, so delete it */ 1015 /* The menu item is no longer valid in ANY mode, so delete it */
1016 #if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF) 1016 #if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
1017 if (s_tearoffs && menu->children != NULL) /* there's a tear bar.. */ 1017 if (s_tearoffs && menu->children != NULL) /* there's a tear bar.. */
1018 free_menu(&menu->children); 1018 free_menu(&menu->children);
1019 #endif 1019 #endif
1020 *menup = menu; 1020 *menup = menu;
1021 free_menu(menup); 1021 free_menu(menup);
1865 { 1865 {
1866 return (name[0] == ']') || (menu_is_popup(name) && name[5] != NUL); 1866 return (name[0] == ']') || (menu_is_popup(name) && name[5] != NUL);
1867 } 1867 }
1868 1868
1869 #if defined(FEAT_CMDL_COMPL) \ 1869 #if defined(FEAT_CMDL_COMPL) \
1870 || (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)) 1870 || (defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF))
1871 /* 1871 /*
1872 * Return TRUE if the menu is the tearoff menu. 1872 * Return TRUE if the menu is the tearoff menu.
1873 */ 1873 */
1874 static int 1874 static int
1875 menu_is_tearoff(char_u *name UNUSED) 1875 menu_is_tearoff(char_u *name UNUSED)
2029 int grey; 2029 int grey;
2030 2030
2031 while (menu) 2031 while (menu)
2032 { 2032 {
2033 if ((menu->modes & menu->enabled & mode) 2033 if ((menu->modes & menu->enabled & mode)
2034 # if defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF) 2034 # if defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)
2035 || menu_is_tearoff(menu->dname) 2035 || menu_is_tearoff(menu->dname)
2036 # endif 2036 # endif
2037 ) 2037 )
2038 grey = FALSE; 2038 grey = FALSE;
2039 else 2039 else
2103 return FALSE; 2103 return FALSE;
2104 } 2104 }
2105 # endif 2105 # endif
2106 #endif /* FEAT_GUI */ 2106 #endif /* FEAT_GUI */
2107 2107
2108 #if (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)) || defined(PROTO) 2108 #if (defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)) || defined(PROTO)
2109 2109
2110 /* 2110 /*
2111 * Deal with tearoff items that are added like a menu item. 2111 * Deal with tearoff items that are added like a menu item.
2112 * Currently only for Win32 GUI. Others may follow later. 2112 * Currently only for Win32 GUI. Others may follow later.
2113 */ 2113 */
2255 } 2255 }
2256 menu = menu->next; 2256 menu = menu->next;
2257 } 2257 }
2258 } 2258 }
2259 2259
2260 #endif /* FEAT_GUI_W32 && FEAT_TEAROFF */ 2260 #endif /* FEAT_GUI_MSWIN && FEAT_TEAROFF */
2261 2261
2262 /* 2262 /*
2263 * Execute "menu". Use by ":emenu" and the window toolbar. 2263 * Execute "menu". Use by ":emenu" and the window toolbar.
2264 * "eap" is NULL for the window toolbar. 2264 * "eap" is NULL for the window toolbar.
2265 * "mode_idx" specifies a MENU_INDEX_ value, use -1 to depend on the current 2265 * "mode_idx" specifies a MENU_INDEX_ value, use -1 to depend on the current