comparison src/menu.c @ 18800:f41b55f9357c v8.1.2388

patch 8.1.2388: using old C style comments Commit: https://github.com/vim/vim/commit/4ba37b5833de99db9e9afe8928b31c864182405c Author: Bram Moolenaar <Bram@vim.org> Date: Wed Dec 4 21:57:43 2019 +0100 patch 8.1.2388: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate.
author Bram Moolenaar <Bram@vim.org>
date Wed, 04 Dec 2019 22:00:04 +0100
parents e9b2ade1adbd
children 22f0dda71638
comparison
equal deleted inserted replaced
18799:d7d0942e231b 18800:f41b55f9357c
14 14
15 #include "vim.h" 15 #include "vim.h"
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_MSWIN 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 *);
54 static void menu_unescape_name(char_u *p); 54 static void menu_unescape_name(char_u *p);
55 #endif 55 #endif
56 56
57 static char_u *menu_translate_tab_and_shift(char_u *arg_start); 57 static char_u *menu_translate_tab_and_shift(char_u *arg_start);
58 58
59 /* The character for each menu mode */ 59 // The character for each menu mode
60 static char *menu_mode_chars[] = {"n", "v", "s", "o", "i", "c", "tl", "t"}; 60 static char *menu_mode_chars[] = {"n", "v", "s", "o", "i", "c", "tl", "t"};
61 61
62 static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu"); 62 static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu");
63 static char_u e_nomenu[] = N_("E329: No menu \"%s\""); 63 static char_u e_nomenu[] = N_("E329: No menu \"%s\"");
64 64
104 /* 104 /*
105 * Do the :menu command and relatives. 105 * Do the :menu command and relatives.
106 */ 106 */
107 void 107 void
108 ex_menu( 108 ex_menu(
109 exarg_T *eap) /* Ex command arguments */ 109 exarg_T *eap) // Ex command arguments
110 { 110 {
111 char_u *menu_path; 111 char_u *menu_path;
112 int modes; 112 int modes;
113 char_u *map_to; 113 char_u *map_to;
114 int noremap; 114 int noremap;
124 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) 124 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
125 int old_toolbar_height; 125 int old_toolbar_height;
126 # endif 126 # endif
127 #endif 127 #endif
128 int pri_tab[MENUDEPTH + 1]; 128 int pri_tab[MENUDEPTH + 1];
129 int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu 129 int enable = MAYBE; // TRUE for "menu enable", FALSE for "menu
130 * disable */ 130 // disable
131 #ifdef FEAT_TOOLBAR 131 #ifdef FEAT_TOOLBAR
132 char_u *icon = NULL; 132 char_u *icon = NULL;
133 #endif 133 #endif
134 vimmenu_T menuarg; 134 vimmenu_T menuarg;
135 vimmenu_T **root_menu_ptr; 135 vimmenu_T **root_menu_ptr;
159 } 159 }
160 break; 160 break;
161 } 161 }
162 162
163 163
164 /* Locate an optional "icon=filename" argument. */ 164 // Locate an optional "icon=filename" argument.
165 if (STRNCMP(arg, "icon=", 5) == 0) 165 if (STRNCMP(arg, "icon=", 5) == 0)
166 { 166 {
167 arg += 5; 167 arg += 5;
168 #ifdef FEAT_TOOLBAR 168 #ifdef FEAT_TOOLBAR
169 icon = arg; 169 icon = arg;
206 } 206 }
207 else 207 else
208 i = 0; 208 i = 0;
209 while (i < MENUDEPTH) 209 while (i < MENUDEPTH)
210 pri_tab[i++] = 500; 210 pri_tab[i++] = 500;
211 pri_tab[MENUDEPTH] = -1; /* mark end of the table */ 211 pri_tab[MENUDEPTH] = -1; // mark end of the table
212 212
213 /* 213 /*
214 * Check for "disable" or "enable" argument. 214 * Check for "disable" or "enable" argument.
215 */ 215 */
216 if (STRNCMP(arg, "enable", 6) == 0 && VIM_ISWHITE(arg[6])) 216 if (STRNCMP(arg, "enable", 6) == 0 && VIM_ISWHITE(arg[6]))
299 # endif 299 # endif
300 #endif 300 #endif
301 301
302 root_menu_ptr = get_root_menu(menu_path); 302 root_menu_ptr = get_root_menu(menu_path);
303 if (root_menu_ptr == &curwin->w_winbar) 303 if (root_menu_ptr == &curwin->w_winbar)
304 /* Assume the window toolbar menu will change. */ 304 // Assume the window toolbar menu will change.
305 redraw_later(NOT_VALID); 305 redraw_later(NOT_VALID);
306 306
307 if (enable != MAYBE) 307 if (enable != MAYBE)
308 { 308 {
309 /* 309 /*
310 * Change sensitivity of the menu. 310 * Change sensitivity of the menu.
311 * For the PopUp menu, remove a menu for each mode separately. 311 * For the PopUp menu, remove a menu for each mode separately.
312 * Careful: menu_nable_recurse() changes menu_path. 312 * Careful: menu_nable_recurse() changes menu_path.
313 */ 313 */
314 if (STRCMP(menu_path, "*") == 0) /* meaning: do all menus */ 314 if (STRCMP(menu_path, "*") == 0) // meaning: do all menus
315 menu_path = (char_u *)""; 315 menu_path = (char_u *)"";
316 316
317 if (menu_is_popup(menu_path)) 317 if (menu_is_popup(menu_path))
318 { 318 {
319 for (i = 0; i < MENU_INDEX_TIP; ++i) 319 for (i = 0; i < MENU_INDEX_TIP; ++i)
333 else if (unmenu) 333 else if (unmenu)
334 { 334 {
335 /* 335 /*
336 * Delete menu(s). 336 * Delete menu(s).
337 */ 337 */
338 if (STRCMP(menu_path, "*") == 0) /* meaning: remove all menus */ 338 if (STRCMP(menu_path, "*") == 0) // meaning: remove all menus
339 menu_path = (char_u *)""; 339 menu_path = (char_u *)"";
340 340
341 /* 341 /*
342 * For the PopUp menu, remove a menu for each mode separately. 342 * For the PopUp menu, remove a menu for each mode separately.
343 */ 343 */
353 vim_free(p); 353 vim_free(p);
354 } 354 }
355 } 355 }
356 } 356 }
357 357
358 /* Careful: remove_menu() changes menu_path */ 358 // Careful: remove_menu() changes menu_path
359 remove_menu(root_menu_ptr, menu_path, modes, FALSE); 359 remove_menu(root_menu_ptr, menu_path, modes, FALSE);
360 } 360 }
361 else 361 else
362 { 362 {
363 /* 363 /*
364 * Add menu(s). 364 * Add menu(s).
365 * Replace special key codes. 365 * Replace special key codes.
366 */ 366 */
367 if (STRICMP(map_to, "<nop>") == 0) /* "<Nop>" means nothing */ 367 if (STRICMP(map_to, "<nop>") == 0) // "<Nop>" means nothing
368 { 368 {
369 map_to = (char_u *)""; 369 map_to = (char_u *)"";
370 map_buf = NULL; 370 map_buf = NULL;
371 } 371 }
372 else if (modes & MENU_TIP_MODE) 372 else if (modes & MENU_TIP_MODE)
373 map_buf = NULL; /* Menu tips are plain text. */ 373 map_buf = NULL; // Menu tips are plain text.
374 else 374 else
375 map_to = replace_termcodes(map_to, &map_buf, 375 map_to = replace_termcodes(map_to, &map_buf,
376 REPTERM_DO_LT | (special ? REPTERM_SPECIAL : 0), NULL); 376 REPTERM_DO_LT | (special ? REPTERM_SPECIAL : 0), NULL);
377 menuarg.modes = modes; 377 menuarg.modes = modes;
378 #ifdef FEAT_TOOLBAR 378 #ifdef FEAT_TOOLBAR
395 if (modes & (1 << i)) 395 if (modes & (1 << i))
396 { 396 {
397 p = popup_mode_name(menu_path, i); 397 p = popup_mode_name(menu_path, i);
398 if (p != NULL) 398 if (p != NULL)
399 { 399 {
400 /* Include all modes, to make ":amenu" work */ 400 // Include all modes, to make ":amenu" work
401 menuarg.modes = modes; 401 menuarg.modes = modes;
402 #ifdef FEAT_TOOLBAR 402 #ifdef FEAT_TOOLBAR
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;
416 416
417 vim_free(map_buf); 417 vim_free(map_buf);
418 } 418 }
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_MSWIN) 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
449 * Add the menu with the given name to the menu hierarchy 449 * Add the menu with the given name to the menu hierarchy
450 */ 450 */
451 static int 451 static int
452 add_menu_path( 452 add_menu_path(
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_MSWIN 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;
464 int modes = menuarg->modes; 464 int modes = menuarg->modes;
484 char_u *en_name; 484 char_u *en_name;
485 char_u *map_to = NULL; 485 char_u *map_to = NULL;
486 #endif 486 #endif
487 vimmenu_T **root_menu_ptr; 487 vimmenu_T **root_menu_ptr;
488 488
489 /* Make a copy so we can stuff around with it, since it could be const */ 489 // Make a copy so we can stuff around with it, since it could be const
490 path_name = vim_strsave(menu_path); 490 path_name = vim_strsave(menu_path);
491 if (path_name == NULL) 491 if (path_name == NULL)
492 return FAIL; 492 return FAIL;
493 root_menu_ptr = get_root_menu(menu_path); 493 root_menu_ptr = get_root_menu(menu_path);
494 menup = root_menu_ptr; 494 menup = root_menu_ptr;
495 parent = NULL; 495 parent = NULL;
496 name = path_name; 496 name = path_name;
497 while (*name) 497 while (*name)
498 { 498 {
499 /* Get name of this element in the menu hierarchy, and the simplified 499 // Get name of this element in the menu hierarchy, and the simplified
500 * name (without mnemonic and accelerator text). */ 500 // name (without mnemonic and accelerator text).
501 next_name = menu_name_skip(name); 501 next_name = menu_name_skip(name);
502 #ifdef FEAT_MULTI_LANG 502 #ifdef FEAT_MULTI_LANG
503 map_to = menutrans_lookup(name, (int)STRLEN(name)); 503 map_to = menutrans_lookup(name, (int)STRLEN(name));
504 if (map_to != NULL) 504 if (map_to != NULL)
505 { 505 {
512 dname = menu_text(name, NULL, NULL); 512 dname = menu_text(name, NULL, NULL);
513 if (dname == NULL) 513 if (dname == NULL)
514 goto erret; 514 goto erret;
515 if (*dname == NUL) 515 if (*dname == NUL)
516 { 516 {
517 /* Only a mnemonic or accelerator is not valid. */ 517 // Only a mnemonic or accelerator is not valid.
518 emsg(_("E792: Empty menu name")); 518 emsg(_("E792: Empty menu name"));
519 goto erret; 519 goto erret;
520 } 520 }
521 521
522 /* See if it's already there */ 522 // See if it's already there
523 lower_pri = menup; 523 lower_pri = menup;
524 #ifdef FEAT_GUI 524 #ifdef FEAT_GUI
525 idx = 0; 525 idx = 0;
526 new_idx = 0; 526 new_idx = 0;
527 #endif 527 #endif
548 } 548 }
549 break; 549 break;
550 } 550 }
551 menup = &menu->next; 551 menup = &menu->next;
552 552
553 /* Count menus, to find where this one needs to be inserted. 553 // Count menus, to find where this one needs to be inserted.
554 * Ignore menus that are not in the menubar (PopUp and Toolbar) */ 554 // Ignore menus that are not in the menubar (PopUp and Toolbar)
555 if (parent != NULL || menu_is_menubar(menu->name)) 555 if (parent != NULL || menu_is_menubar(menu->name))
556 { 556 {
557 #ifdef FEAT_GUI 557 #ifdef FEAT_GUI
558 ++idx; 558 ++idx;
559 #endif 559 #endif
580 { 580 {
581 emsg(_("E332: Separator cannot be part of a menu path")); 581 emsg(_("E332: Separator cannot be part of a menu path"));
582 goto erret; 582 goto erret;
583 } 583 }
584 584
585 /* Not already there, so lets add it */ 585 // Not already there, so lets add it
586 menu = ALLOC_CLEAR_ONE(vimmenu_T); 586 menu = ALLOC_CLEAR_ONE(vimmenu_T);
587 if (menu == NULL) 587 if (menu == NULL)
588 goto erret; 588 goto erret;
589 589
590 menu->modes = modes; 590 menu->modes = modes;
591 menu->enabled = MENU_ALL_MODES; 591 menu->enabled = MENU_ALL_MODES;
592 menu->name = vim_strsave(name); 592 menu->name = vim_strsave(name);
593 /* separate mnemonic and accelerator text from actual menu name */ 593 // separate mnemonic and accelerator text from actual menu name
594 menu->dname = menu_text(name, &menu->mnemonic, &menu->actext); 594 menu->dname = menu_text(name, &menu->mnemonic, &menu->actext);
595 #ifdef FEAT_MULTI_LANG 595 #ifdef FEAT_MULTI_LANG
596 if (en_name != NULL) 596 if (en_name != NULL)
597 { 597 {
598 menu->en_name = vim_strsave(en_name); 598 menu->en_name = vim_strsave(en_name);
605 } 605 }
606 #endif 606 #endif
607 menu->priority = pri_tab[pri_idx]; 607 menu->priority = pri_tab[pri_idx];
608 menu->parent = parent; 608 menu->parent = parent;
609 #ifdef FEAT_GUI_MOTIF 609 #ifdef FEAT_GUI_MOTIF
610 menu->sensitive = TRUE; /* the default */ 610 menu->sensitive = TRUE; // the default
611 #endif 611 #endif
612 #ifdef FEAT_BEVAL_TIP 612 #ifdef FEAT_BEVAL_TIP
613 menu->tip = NULL; 613 menu->tip = NULL;
614 #endif 614 #endif
615 #ifdef FEAT_GUI_ATHENA 615 #ifdef FEAT_GUI_ATHENA
616 menu->image = None; /* X-Windows definition for NULL*/ 616 menu->image = None; // X-Windows definition for NULL
617 #endif 617 #endif
618 618
619 /* 619 /*
620 * Add after menu that has lower priority. 620 * Add after menu that has lower priority.
621 */ 621 */
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_MSWIN) && 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 }
639 else 639 else
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_MSWIN 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;
654 menu->enabled |= modes; 654 menu->enabled |= modes;
661 * only a tooltip is defined. 661 * only a tooltip is defined.
662 */ 662 */
663 if ((old_modes & MENU_ALL_MODES) == 0 663 if ((old_modes & MENU_ALL_MODES) == 0
664 && (menu->modes & MENU_ALL_MODES) != 0) 664 && (menu->modes & MENU_ALL_MODES) != 0)
665 { 665 {
666 if (gui.in_use) /* Otherwise it will be added when GUI starts */ 666 if (gui.in_use) // Otherwise it will be added when GUI starts
667 { 667 {
668 if (*next_name == NUL) 668 if (*next_name == NUL)
669 { 669 {
670 /* Real menu item, not sub-menu */ 670 // Real menu item, not sub-menu
671 gui_mch_add_menu_item(menu, new_idx); 671 gui_mch_add_menu_item(menu, new_idx);
672 672
673 /* Want to update menus now even if mode not changed */ 673 // Want to update menus now even if mode not changed
674 force_menu_update = TRUE; 674 force_menu_update = TRUE;
675 } 675 }
676 else 676 else
677 { 677 {
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_MSWIN) & 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)
689 # ifdef VIMDLL 689 # ifdef VIMDLL
719 vim_free(tearpath); 719 vim_free(tearpath);
720 } 720 }
721 } 721 }
722 # endif 722 # endif
723 } 723 }
724 #endif /* FEAT_GUI */ 724 #endif // FEAT_GUI
725 725
726 menup = &menu->children; 726 menup = &menu->children;
727 parent = menu; 727 parent = menu;
728 name = next_name; 728 name = next_name;
729 VIM_CLEAR(dname); 729 VIM_CLEAR(dname);
746 #ifdef FEAT_GUI 746 #ifdef FEAT_GUI
747 menu->cb = gui_menu_cb; 747 menu->cb = gui_menu_cb;
748 #endif 748 #endif
749 p = (call_data == NULL) ? NULL : vim_strsave(call_data); 749 p = (call_data == NULL) ? NULL : vim_strsave(call_data);
750 750
751 /* loop over all modes, may add more than one */ 751 // loop over all modes, may add more than one
752 for (i = 0; i < MENU_MODES; ++i) 752 for (i = 0; i < MENU_MODES; ++i)
753 { 753 {
754 if (modes & (1 << i)) 754 if (modes & (1 << i))
755 { 755 {
756 /* free any old menu */ 756 // free any old menu
757 free_menu_string(menu, i); 757 free_menu_string(menu, i);
758 758
759 /* For "amenu", may insert an extra character. 759 // For "amenu", may insert an extra character.
760 * Don't do this if adding a tearbar (addtearoff == FALSE). 760 // Don't do this if adding a tearbar (addtearoff == FALSE).
761 * Don't do this for "<Nop>". */ 761 // Don't do this for "<Nop>".
762 c = 0; 762 c = 0;
763 d = 0; 763 d = 0;
764 if (amenu && call_data != NULL && *call_data != NUL 764 if (amenu && call_data != NULL && *call_data != NUL
765 #ifdef FEAT_GUI_MSWIN 765 #ifdef FEAT_GUI_MSWIN
766 && addtearoff 766 && addtearoff
797 } 797 }
798 if (c == Ctrl_C) 798 if (c == Ctrl_C)
799 { 799 {
800 int len = (int)STRLEN(menu->strings[i]); 800 int len = (int)STRLEN(menu->strings[i]);
801 801
802 /* Append CTRL-\ CTRL-G to obey 'insertmode'. */ 802 // Append CTRL-\ CTRL-G to obey 'insertmode'.
803 menu->strings[i][len] = Ctrl_BSL; 803 menu->strings[i][len] = Ctrl_BSL;
804 menu->strings[i][len + 1] = Ctrl_G; 804 menu->strings[i][len + 1] = Ctrl_G;
805 menu->strings[i][len + 2] = NUL; 805 menu->strings[i][len + 2] = NUL;
806 } 806 }
807 } 807 }
812 menu->silent[i] = menuarg->silent[0]; 812 menu->silent[i] = menuarg->silent[0];
813 } 813 }
814 } 814 }
815 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \ 815 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \
816 && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK)) 816 && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK))
817 /* Need to update the menu tip. */ 817 // Need to update the menu tip.
818 if (modes & MENU_TIP_MODE) 818 if (modes & MENU_TIP_MODE)
819 gui_mch_menu_set_tip(menu); 819 gui_mch_menu_set_tip(menu);
820 #endif 820 #endif
821 } 821 }
822 return OK; 822 return OK;
823 823
824 erret: 824 erret:
825 vim_free(path_name); 825 vim_free(path_name);
826 vim_free(dname); 826 vim_free(dname);
827 827
828 /* Delete any empty submenu we added before discovering the error. Repeat 828 // Delete any empty submenu we added before discovering the error. Repeat
829 * for higher levels. */ 829 // for higher levels.
830 while (parent != NULL && parent->children == NULL) 830 while (parent != NULL && parent->children == NULL)
831 { 831 {
832 if (parent->parent == NULL) 832 if (parent->parent == NULL)
833 menup = root_menu_ptr; 833 menup = root_menu_ptr;
834 else 834 else
835 menup = &parent->parent->children; 835 menup = &parent->parent->children;
836 for ( ; *menup != NULL && *menup != parent; menup = &((*menup)->next)) 836 for ( ; *menup != NULL && *menup != parent; menup = &((*menup)->next))
837 ; 837 ;
838 if (*menup == NULL) /* safety check */ 838 if (*menup == NULL) // safety check
839 break; 839 break;
840 parent = parent->parent; 840 parent = parent->parent;
841 free_menu(menup); 841 free_menu(menup);
842 } 842 }
843 return FAIL; 843 return FAIL;
855 int enable) 855 int enable)
856 { 856 {
857 char_u *p; 857 char_u *p;
858 858
859 if (menu == NULL) 859 if (menu == NULL)
860 return OK; /* Got to bottom of hierarchy */ 860 return OK; // Got to bottom of hierarchy
861 861
862 /* Get name of this element in the menu hierarchy */ 862 // Get name of this element in the menu hierarchy
863 p = menu_name_skip(name); 863 p = menu_name_skip(name);
864 864
865 /* Find the menu */ 865 // Find the menu
866 while (menu != NULL) 866 while (menu != NULL)
867 { 867 {
868 if (*name == NUL || *name == '*' || menu_name_equal(name, menu)) 868 if (*name == NUL || *name == '*' || menu_name_equal(name, menu))
869 { 869 {
870 if (*p != NUL) 870 if (*p != NUL)
899 semsg(_(e_nomenu), name); 899 semsg(_(e_nomenu), name);
900 return FAIL; 900 return FAIL;
901 } 901 }
902 902
903 #ifdef FEAT_GUI 903 #ifdef FEAT_GUI
904 /* Want to update menus now even if mode not changed */ 904 // Want to update menus now even if mode not changed
905 force_menu_update = TRUE; 905 force_menu_update = TRUE;
906 #endif 906 #endif
907 907
908 return OK; 908 return OK;
909 } 909 }
915 static int 915 static int
916 remove_menu( 916 remove_menu(
917 vimmenu_T **menup, 917 vimmenu_T **menup,
918 char_u *name, 918 char_u *name,
919 int modes, 919 int modes,
920 int silent) /* don't give error messages */ 920 int silent) // don't give error messages
921 { 921 {
922 vimmenu_T *menu; 922 vimmenu_T *menu;
923 vimmenu_T *child; 923 vimmenu_T *child;
924 char_u *p; 924 char_u *p;
925 925
926 if (*menup == NULL) 926 if (*menup == NULL)
927 return OK; /* Got to bottom of hierarchy */ 927 return OK; // Got to bottom of hierarchy
928 928
929 /* Get name of this element in the menu hierarchy */ 929 // Get name of this element in the menu hierarchy
930 p = menu_name_skip(name); 930 p = menu_name_skip(name);
931 931
932 /* Find the menu */ 932 // Find the menu
933 while ((menu = *menup) != NULL) 933 while ((menu = *menup) != NULL)
934 { 934 {
935 if (*name == NUL || menu_name_equal(name, menu)) 935 if (*name == NUL || menu_name_equal(name, menu))
936 { 936 {
937 if (*p != NUL && menu->children == NULL) 937 if (*p != NUL && menu->children == NULL)
969 * menu item (which has been found) so break here. 969 * menu item (which has been found) so break here.
970 */ 970 */
971 if (*name != NUL) 971 if (*name != NUL)
972 break; 972 break;
973 973
974 /* Remove the menu item for the given mode[s]. If the menu item 974 // Remove the menu item for the given mode[s]. If the menu item
975 * is no longer valid in ANY mode, delete it */ 975 // is no longer valid in ANY mode, delete it
976 menu->modes &= ~modes; 976 menu->modes &= ~modes;
977 if (modes & MENU_TIP_MODE) 977 if (modes & MENU_TIP_MODE)
978 free_menu_string(menu, MENU_INDEX_TIP); 978 free_menu_string(menu, MENU_INDEX_TIP);
979 if ((menu->modes & MENU_ALL_MODES) == 0) 979 if ((menu->modes & MENU_ALL_MODES) == 0)
980 free_menu(menup); 980 free_menu(menup);
992 semsg(_(e_nomenu), name); 992 semsg(_(e_nomenu), name);
993 return FAIL; 993 return FAIL;
994 } 994 }
995 995
996 996
997 /* Recalculate modes for menu based on the new updated children */ 997 // Recalculate modes for menu based on the new updated children
998 menu->modes &= ~modes; 998 menu->modes &= ~modes;
999 #if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF) 999 #if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
1000 if ((s_tearoffs) && (menu->children != NULL)) /* there's a tear bar.. */ 1000 if ((s_tearoffs) && (menu->children != NULL)) // there's a tear bar..
1001 child = menu->children->next; /* don't count tearoff bar */ 1001 child = menu->children->next; // don't count tearoff bar
1002 else 1002 else
1003 #endif 1003 #endif
1004 child = menu->children; 1004 child = menu->children;
1005 for ( ; child != NULL; child = child->next) 1005 for ( ; child != NULL; child = child->next)
1006 menu->modes |= child->modes; 1006 menu->modes |= child->modes;
1007 if (modes & MENU_TIP_MODE) 1007 if (modes & MENU_TIP_MODE)
1008 { 1008 {
1009 free_menu_string(menu, MENU_INDEX_TIP); 1009 free_menu_string(menu, MENU_INDEX_TIP);
1010 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \ 1010 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN) \
1011 && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK)) 1011 && (defined(FEAT_BEVAL_GUI) || defined(FEAT_GUI_GTK))
1012 /* Need to update the menu tip. */ 1012 // Need to update the menu tip.
1013 if (gui.in_use) 1013 if (gui.in_use)
1014 gui_mch_menu_set_tip(menu); 1014 gui_mch_menu_set_tip(menu);
1015 #endif 1015 #endif
1016 } 1016 }
1017 if ((menu->modes & MENU_ALL_MODES) == 0) 1017 if ((menu->modes & MENU_ALL_MODES) == 0)
1018 { 1018 {
1019 /* The menu item is no longer valid in ANY mode, so delete it */ 1019 // The menu item is no longer valid in ANY mode, so delete it
1020 #if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF) 1020 #if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
1021 if (s_tearoffs && menu->children != NULL) /* there's a tear bar.. */ 1021 if (s_tearoffs && menu->children != NULL) // there's a tear bar..
1022 free_menu(&menu->children); 1022 free_menu(&menu->children);
1023 #endif 1023 #endif
1024 *menup = menu; 1024 *menup = menu;
1025 free_menu(menup); 1025 free_menu(menup);
1026 } 1026 }
1049 vimmenu_T *menu; 1049 vimmenu_T *menu;
1050 1050
1051 menu = *menup; 1051 menu = *menup;
1052 1052
1053 #ifdef FEAT_GUI 1053 #ifdef FEAT_GUI
1054 /* Free machine specific menu structures (only when already created) */ 1054 // Free machine specific menu structures (only when already created)
1055 /* Also may rebuild a tearoff'ed menu */ 1055 // Also may rebuild a tearoff'ed menu
1056 if (gui.in_use) 1056 if (gui.in_use)
1057 gui_mch_destroy_menu(menu); 1057 gui_mch_destroy_menu(menu);
1058 #endif 1058 #endif
1059 1059
1060 /* Don't change *menup until after calling gui_mch_destroy_menu(). The 1060 // Don't change *menup until after calling gui_mch_destroy_menu(). The
1061 * MacOS code needs the original structure to properly delete the menu. */ 1061 // MacOS code needs the original structure to properly delete the menu.
1062 *menup = menu->next; 1062 *menup = menu->next;
1063 vim_free(menu->name); 1063 vim_free(menu->name);
1064 vim_free(menu->dname); 1064 vim_free(menu->dname);
1065 #ifdef FEAT_MULTI_LANG 1065 #ifdef FEAT_MULTI_LANG
1066 vim_free(menu->en_name); 1066 vim_free(menu->en_name);
1076 for (i = 0; i < MENU_MODES; i++) 1076 for (i = 0; i < MENU_MODES; i++)
1077 free_menu_string(menu, i); 1077 free_menu_string(menu, i);
1078 vim_free(menu); 1078 vim_free(menu);
1079 1079
1080 #ifdef FEAT_GUI 1080 #ifdef FEAT_GUI
1081 /* Want to update menus now even if mode not changed */ 1081 // Want to update menus now even if mode not changed
1082 force_menu_update = TRUE; 1082 force_menu_update = TRUE;
1083 #endif 1083 #endif
1084 } 1084 }
1085 1085
1086 /* 1086 /*
1114 name = path_name = vim_strsave(path_name); 1114 name = path_name = vim_strsave(path_name);
1115 if (path_name == NULL) 1115 if (path_name == NULL)
1116 return FAIL; 1116 return FAIL;
1117 menu = *get_root_menu(path_name); 1117 menu = *get_root_menu(path_name);
1118 1118
1119 /* First, find the (sub)menu with the given name */ 1119 // First, find the (sub)menu with the given name
1120 while (*name) 1120 while (*name)
1121 { 1121 {
1122 p = menu_name_skip(name); 1122 p = menu_name_skip(name);
1123 while (menu != NULL) 1123 while (menu != NULL)
1124 { 1124 {
1125 if (menu_name_equal(name, menu)) 1125 if (menu_name_equal(name, menu))
1126 { 1126 {
1127 /* Found menu */ 1127 // Found menu
1128 if (*p != NUL && menu->children == NULL) 1128 if (*p != NUL && menu->children == NULL)
1129 { 1129 {
1130 emsg(_(e_notsubmenu)); 1130 emsg(_(e_notsubmenu));
1131 vim_free(path_name); 1131 vim_free(path_name);
1132 return FAIL; 1132 return FAIL;
1151 parent = menu; 1151 parent = menu;
1152 menu = menu->children; 1152 menu = menu->children;
1153 } 1153 }
1154 vim_free(path_name); 1154 vim_free(path_name);
1155 1155
1156 /* Now we have found the matching menu, and we list the mappings */ 1156 // Now we have found the matching menu, and we list the mappings
1157 /* Highlight title */ 1157 // Highlight title
1158 msg_puts_title(_("\n--- Menus ---")); 1158 msg_puts_title(_("\n--- Menus ---"));
1159 1159
1160 show_menus_recursive(parent, modes, 0); 1160 show_menus_recursive(parent, modes, 0);
1161 return OK; 1161 return OK;
1162 } 1162 }
1174 return; 1174 return;
1175 1175
1176 if (menu != NULL) 1176 if (menu != NULL)
1177 { 1177 {
1178 msg_putchar('\n'); 1178 msg_putchar('\n');
1179 if (got_int) /* "q" hit for "--more--" */ 1179 if (got_int) // "q" hit for "--more--"
1180 return; 1180 return;
1181 for (i = 0; i < depth; i++) 1181 for (i = 0; i < depth; i++)
1182 msg_puts(" "); 1182 msg_puts(" ");
1183 if (menu->priority) 1183 if (menu->priority)
1184 { 1184 {
1185 msg_outnum((long)menu->priority); 1185 msg_outnum((long)menu->priority);
1186 msg_puts(" "); 1186 msg_puts(" ");
1187 } 1187 }
1188 /* Same highlighting as for directories!? */ 1188 // Same highlighting as for directories!?
1189 msg_outtrans_attr(menu->name, HL_ATTR(HLF_D)); 1189 msg_outtrans_attr(menu->name, HL_ATTR(HLF_D));
1190 } 1190 }
1191 1191
1192 if (menu != NULL && menu->children == NULL) 1192 if (menu != NULL && menu->children == NULL)
1193 { 1193 {
1194 for (bit = 0; bit < MENU_MODES; bit++) 1194 for (bit = 0; bit < MENU_MODES; bit++)
1195 if ((menu->modes & modes & (1 << bit)) != 0) 1195 if ((menu->modes & modes & (1 << bit)) != 0)
1196 { 1196 {
1197 msg_putchar('\n'); 1197 msg_putchar('\n');
1198 if (got_int) /* "q" hit for "--more--" */ 1198 if (got_int) // "q" hit for "--more--"
1199 return; 1199 return;
1200 for (i = 0; i < depth + 2; i++) 1200 for (i = 0; i < depth + 2; i++)
1201 msg_puts(" "); 1201 msg_puts(" ");
1202 msg_puts(menu_mode_chars[bit]); 1202 msg_puts(menu_mode_chars[bit]);
1203 if (menu->noremap[bit] == REMAP_NONE) 1203 if (menu->noremap[bit] == REMAP_NONE)
1229 depth--; 1229 depth--;
1230 } 1230 }
1231 else 1231 else
1232 menu = menu->children; 1232 menu = menu->children;
1233 1233
1234 /* recursively show all children. Skip PopUp[nvoci]. */ 1234 // recursively show all children. Skip PopUp[nvoci].
1235 for (; menu != NULL && !got_int; menu = menu->next) 1235 for (; menu != NULL && !got_int; menu = menu->next)
1236 if (!menu_is_hidden(menu->dname)) 1236 if (!menu_is_hidden(menu->dname))
1237 show_menus_recursive(menu, modes, depth + 1); 1237 show_menus_recursive(menu, modes, depth + 1);
1238 } 1238 }
1239 } 1239 }
1242 * Used when expanding menu names. 1242 * Used when expanding menu names.
1243 */ 1243 */
1244 static vimmenu_T *expand_menu = NULL; 1244 static vimmenu_T *expand_menu = NULL;
1245 static vimmenu_T *expand_menu_alt = NULL; 1245 static vimmenu_T *expand_menu_alt = NULL;
1246 static int expand_modes = 0x0; 1246 static int expand_modes = 0x0;
1247 static int expand_emenu; /* TRUE for ":emenu" command */ 1247 static int expand_emenu; // TRUE for ":emenu" command
1248 1248
1249 /* 1249 /*
1250 * Work out what to complete when doing command line completion of menu names. 1250 * Work out what to complete when doing command line completion of menu names.
1251 */ 1251 */
1252 char_u * 1252 char_u *
1265 int expand_menus; 1265 int expand_menus;
1266 1266
1267 xp->xp_context = EXPAND_UNSUCCESSFUL; 1267 xp->xp_context = EXPAND_UNSUCCESSFUL;
1268 1268
1269 1269
1270 /* Check for priority numbers, enable and disable */ 1270 // Check for priority numbers, enable and disable
1271 for (p = arg; *p; ++p) 1271 for (p = arg; *p; ++p)
1272 if (!VIM_ISDIGIT(*p) && *p != '.') 1272 if (!VIM_ISDIGIT(*p) && *p != '.')
1273 break; 1273 break;
1274 1274
1275 if (!VIM_ISWHITE(*p)) 1275 if (!VIM_ISWHITE(*p))
1295 p++; 1295 p++;
1296 else if (*p == '.') 1296 else if (*p == '.')
1297 after_dot = p + 1; 1297 after_dot = p + 1;
1298 } 1298 }
1299 1299
1300 /* ":tearoff" and ":popup" only use menus, not entries */ 1300 // ":tearoff" and ":popup" only use menus, not entries
1301 expand_menus = !((*cmd == 't' && cmd[1] == 'e') || *cmd == 'p'); 1301 expand_menus = !((*cmd == 't' && cmd[1] == 'e') || *cmd == 'p');
1302 expand_emenu = (*cmd == 'e'); 1302 expand_emenu = (*cmd == 'e');
1303 if (expand_menus && VIM_ISWHITE(*p)) 1303 if (expand_menus && VIM_ISWHITE(*p))
1304 return NULL; /* TODO: check for next command? */ 1304 return NULL; // TODO: check for next command?
1305 if (*p == NUL) /* Complete the menu name */ 1305 if (*p == NUL) // Complete the menu name
1306 { 1306 {
1307 int try_alt_menu = TRUE; 1307 int try_alt_menu = TRUE;
1308 1308
1309 /* 1309 /*
1310 * With :unmenu, you only want to match menus for the appropriate mode. 1310 * With :unmenu, you only want to match menus for the appropriate mode.
1329 p = menu_name_skip(name); 1329 p = menu_name_skip(name);
1330 while (menu != NULL) 1330 while (menu != NULL)
1331 { 1331 {
1332 if (menu_name_equal(name, menu)) 1332 if (menu_name_equal(name, menu))
1333 { 1333 {
1334 /* Found menu */ 1334 // Found menu
1335 if ((*p != NUL && menu->children == NULL) 1335 if ((*p != NUL && menu->children == NULL)
1336 || ((menu->modes & expand_modes) == 0x0)) 1336 || ((menu->modes & expand_modes) == 0x0))
1337 { 1337 {
1338 /* 1338 /*
1339 * Menu path continues, but we have reached a leaf. 1339 * Menu path continues, but we have reached a leaf.
1351 try_alt_menu = FALSE; 1351 try_alt_menu = FALSE;
1352 } 1352 }
1353 } 1353 }
1354 if (menu == NULL) 1354 if (menu == NULL)
1355 { 1355 {
1356 /* No menu found with the name we were looking for */ 1356 // No menu found with the name we were looking for
1357 vim_free(path_name); 1357 vim_free(path_name);
1358 return NULL; 1358 return NULL;
1359 } 1359 }
1360 name = p; 1360 name = p;
1361 menu = menu->children; 1361 menu = menu->children;
1369 if (expand_menu == root_menu) 1369 if (expand_menu == root_menu)
1370 expand_menu_alt = curwin->w_winbar; 1370 expand_menu_alt = curwin->w_winbar;
1371 else 1371 else
1372 expand_menu_alt = NULL; 1372 expand_menu_alt = NULL;
1373 } 1373 }
1374 else /* We're in the mapping part */ 1374 else // We're in the mapping part
1375 xp->xp_context = EXPAND_NOTHING; 1375 xp->xp_context = EXPAND_NOTHING;
1376 return NULL; 1376 return NULL;
1377 } 1377 }
1378 1378
1379 /* 1379 /*
1388 char_u *str; 1388 char_u *str;
1389 #ifdef FEAT_MULTI_LANG 1389 #ifdef FEAT_MULTI_LANG
1390 static int should_advance = FALSE; 1390 static int should_advance = FALSE;
1391 #endif 1391 #endif
1392 1392
1393 if (idx == 0) /* first call: start at first item */ 1393 if (idx == 0) // first call: start at first item
1394 { 1394 {
1395 menu = expand_menu; 1395 menu = expand_menu;
1396 did_alt_menu = FALSE; 1396 did_alt_menu = FALSE;
1397 #ifdef FEAT_MULTI_LANG 1397 #ifdef FEAT_MULTI_LANG
1398 should_advance = FALSE; 1398 should_advance = FALSE;
1399 #endif 1399 #endif
1400 } 1400 }
1401 1401
1402 /* Skip PopUp[nvoci]. */ 1402 // Skip PopUp[nvoci].
1403 while (menu != NULL && (menu_is_hidden(menu->dname) 1403 while (menu != NULL && (menu_is_hidden(menu->dname)
1404 || menu_is_separator(menu->dname) 1404 || menu_is_separator(menu->dname)
1405 || menu_is_tearoff(menu->dname) 1405 || menu_is_tearoff(menu->dname)
1406 || menu->children == NULL)) 1406 || menu->children == NULL))
1407 { 1407 {
1411 menu = expand_menu_alt; 1411 menu = expand_menu_alt;
1412 did_alt_menu = TRUE; 1412 did_alt_menu = TRUE;
1413 } 1413 }
1414 } 1414 }
1415 1415
1416 if (menu == NULL) /* at end of linked list */ 1416 if (menu == NULL) // at end of linked list
1417 return NULL; 1417 return NULL;
1418 1418
1419 if (menu->modes & expand_modes) 1419 if (menu->modes & expand_modes)
1420 #ifdef FEAT_MULTI_LANG 1420 #ifdef FEAT_MULTI_LANG
1421 if (should_advance) 1421 if (should_advance)
1434 1434
1435 #ifdef FEAT_MULTI_LANG 1435 #ifdef FEAT_MULTI_LANG
1436 if (should_advance) 1436 if (should_advance)
1437 #endif 1437 #endif
1438 { 1438 {
1439 /* Advance to next menu entry. */ 1439 // Advance to next menu entry.
1440 menu = menu->next; 1440 menu = menu->next;
1441 if (menu == NULL && !did_alt_menu) 1441 if (menu == NULL && !did_alt_menu)
1442 { 1442 {
1443 menu = expand_menu_alt; 1443 menu = expand_menu_alt;
1444 did_alt_menu = TRUE; 1444 did_alt_menu = TRUE;
1460 get_menu_names(expand_T *xp UNUSED, int idx) 1460 get_menu_names(expand_T *xp UNUSED, int idx)
1461 { 1461 {
1462 static vimmenu_T *menu = NULL; 1462 static vimmenu_T *menu = NULL;
1463 static int did_alt_menu = FALSE; 1463 static int did_alt_menu = FALSE;
1464 #define TBUFFER_LEN 256 1464 #define TBUFFER_LEN 256
1465 static char_u tbuffer[TBUFFER_LEN]; /*hack*/ 1465 static char_u tbuffer[TBUFFER_LEN]; //hack
1466 char_u *str; 1466 char_u *str;
1467 #ifdef FEAT_MULTI_LANG 1467 #ifdef FEAT_MULTI_LANG
1468 static int should_advance = FALSE; 1468 static int should_advance = FALSE;
1469 #endif 1469 #endif
1470 1470
1471 if (idx == 0) /* first call: start at first item */ 1471 if (idx == 0) // first call: start at first item
1472 { 1472 {
1473 menu = expand_menu; 1473 menu = expand_menu;
1474 did_alt_menu = FALSE; 1474 did_alt_menu = FALSE;
1475 #ifdef FEAT_MULTI_LANG 1475 #ifdef FEAT_MULTI_LANG
1476 should_advance = FALSE; 1476 should_advance = FALSE;
1477 #endif 1477 #endif
1478 } 1478 }
1479 1479
1480 /* Skip Browse-style entries, popup menus and separators. */ 1480 // Skip Browse-style entries, popup menus and separators.
1481 while (menu != NULL 1481 while (menu != NULL
1482 && ( menu_is_hidden(menu->dname) 1482 && ( menu_is_hidden(menu->dname)
1483 || (expand_emenu && menu_is_separator(menu->dname)) 1483 || (expand_emenu && menu_is_separator(menu->dname))
1484 || menu_is_tearoff(menu->dname) 1484 || menu_is_tearoff(menu->dname)
1485 #ifndef FEAT_BROWSE 1485 #ifndef FEAT_BROWSE
1493 menu = expand_menu_alt; 1493 menu = expand_menu_alt;
1494 did_alt_menu = TRUE; 1494 did_alt_menu = TRUE;
1495 } 1495 }
1496 } 1496 }
1497 1497
1498 if (menu == NULL) /* at end of linked list */ 1498 if (menu == NULL) // at end of linked list
1499 return NULL; 1499 return NULL;
1500 1500
1501 if (menu->modes & expand_modes) 1501 if (menu->modes & expand_modes)
1502 { 1502 {
1503 if (menu->children != NULL) 1503 if (menu->children != NULL)
1512 #ifdef FEAT_MULTI_LANG 1512 #ifdef FEAT_MULTI_LANG
1513 if (menu->en_dname == NULL) 1513 if (menu->en_dname == NULL)
1514 should_advance = TRUE; 1514 should_advance = TRUE;
1515 } 1515 }
1516 #endif 1516 #endif
1517 /* hack on menu separators: use a 'magic' char for the separator 1517 // hack on menu separators: use a 'magic' char for the separator
1518 * so that '.' in names gets escaped properly */ 1518 // so that '.' in names gets escaped properly
1519 STRCAT(tbuffer, "\001"); 1519 STRCAT(tbuffer, "\001");
1520 str = tbuffer; 1520 str = tbuffer;
1521 } 1521 }
1522 else 1522 else
1523 #ifdef FEAT_MULTI_LANG 1523 #ifdef FEAT_MULTI_LANG
1540 1540
1541 #ifdef FEAT_MULTI_LANG 1541 #ifdef FEAT_MULTI_LANG
1542 if (should_advance) 1542 if (should_advance)
1543 #endif 1543 #endif
1544 { 1544 {
1545 /* Advance to next menu entry. */ 1545 // Advance to next menu entry.
1546 menu = menu->next; 1546 menu = menu->next;
1547 if (menu == NULL && !did_alt_menu) 1547 if (menu == NULL && !did_alt_menu)
1548 { 1548 {
1549 menu = expand_menu_alt; 1549 menu = expand_menu_alt;
1550 did_alt_menu = TRUE; 1550 did_alt_menu = TRUE;
1619 * whether the command is an "unmenu" command. 1619 * whether the command is an "unmenu" command.
1620 */ 1620 */
1621 static int 1621 static int
1622 get_menu_cmd_modes( 1622 get_menu_cmd_modes(
1623 char_u *cmd, 1623 char_u *cmd,
1624 int forceit, /* Was there a "!" after the command? */ 1624 int forceit, // Was there a "!" after the command?
1625 int *noremap, 1625 int *noremap,
1626 int *unmenu) 1626 int *unmenu)
1627 { 1627 {
1628 int modes; 1628 int modes;
1629 1629
1630 switch (*cmd++) 1630 switch (*cmd++)
1631 { 1631 {
1632 case 'v': /* vmenu, vunmenu, vnoremenu */ 1632 case 'v': // vmenu, vunmenu, vnoremenu
1633 modes = MENU_VISUAL_MODE | MENU_SELECT_MODE; 1633 modes = MENU_VISUAL_MODE | MENU_SELECT_MODE;
1634 break; 1634 break;
1635 case 'x': /* xmenu, xunmenu, xnoremenu */ 1635 case 'x': // xmenu, xunmenu, xnoremenu
1636 modes = MENU_VISUAL_MODE; 1636 modes = MENU_VISUAL_MODE;
1637 break; 1637 break;
1638 case 's': /* smenu, sunmenu, snoremenu */ 1638 case 's': // smenu, sunmenu, snoremenu
1639 modes = MENU_SELECT_MODE; 1639 modes = MENU_SELECT_MODE;
1640 break; 1640 break;
1641 case 'o': /* omenu */ 1641 case 'o': // omenu
1642 modes = MENU_OP_PENDING_MODE; 1642 modes = MENU_OP_PENDING_MODE;
1643 break; 1643 break;
1644 case 'i': /* imenu */ 1644 case 'i': // imenu
1645 modes = MENU_INSERT_MODE; 1645 modes = MENU_INSERT_MODE;
1646 break; 1646 break;
1647 case 't': 1647 case 't':
1648 if (*cmd == 'l') /* tlmenu, tlunmenu, tlnoremenu */ 1648 if (*cmd == 'l') // tlmenu, tlunmenu, tlnoremenu
1649 { 1649 {
1650 modes = MENU_TERMINAL_MODE; 1650 modes = MENU_TERMINAL_MODE;
1651 ++cmd; 1651 ++cmd;
1652 break; 1652 break;
1653 } 1653 }
1654 modes = MENU_TIP_MODE; /* tmenu */ 1654 modes = MENU_TIP_MODE; // tmenu
1655 break; 1655 break;
1656 case 'c': /* cmenu */ 1656 case 'c': // cmenu
1657 modes = MENU_CMDLINE_MODE; 1657 modes = MENU_CMDLINE_MODE;
1658 break; 1658 break;
1659 case 'a': /* amenu */ 1659 case 'a': // amenu
1660 modes = MENU_INSERT_MODE | MENU_CMDLINE_MODE | MENU_NORMAL_MODE 1660 modes = MENU_INSERT_MODE | MENU_CMDLINE_MODE | MENU_NORMAL_MODE
1661 | MENU_VISUAL_MODE | MENU_SELECT_MODE 1661 | MENU_VISUAL_MODE | MENU_SELECT_MODE
1662 | MENU_OP_PENDING_MODE; 1662 | MENU_OP_PENDING_MODE;
1663 break; 1663 break;
1664 case 'n': 1664 case 'n':
1665 if (*cmd != 'o') /* nmenu, not noremenu */ 1665 if (*cmd != 'o') // nmenu, not noremenu
1666 { 1666 {
1667 modes = MENU_NORMAL_MODE; 1667 modes = MENU_NORMAL_MODE;
1668 break; 1668 break;
1669 } 1669 }
1670 /* FALLTHROUGH */ 1670 // FALLTHROUGH
1671 default: 1671 default:
1672 --cmd; 1672 --cmd;
1673 if (forceit) /* menu!! */ 1673 if (forceit) // menu!!
1674 modes = MENU_INSERT_MODE | MENU_CMDLINE_MODE; 1674 modes = MENU_INSERT_MODE | MENU_CMDLINE_MODE;
1675 else /* menu */ 1675 else // menu
1676 modes = MENU_NORMAL_MODE | MENU_VISUAL_MODE | MENU_SELECT_MODE 1676 modes = MENU_NORMAL_MODE | MENU_VISUAL_MODE | MENU_SELECT_MODE
1677 | MENU_OP_PENDING_MODE; 1677 | MENU_OP_PENDING_MODE;
1678 } 1678 }
1679 1679
1680 if (noremap != NULL) 1680 if (noremap != NULL)
1759 menu_text(char_u *str, int *mnemonic, char_u **actext) 1759 menu_text(char_u *str, int *mnemonic, char_u **actext)
1760 { 1760 {
1761 char_u *p; 1761 char_u *p;
1762 char_u *text; 1762 char_u *text;
1763 1763
1764 /* Locate accelerator text, after the first TAB */ 1764 // Locate accelerator text, after the first TAB
1765 p = vim_strchr(str, TAB); 1765 p = vim_strchr(str, TAB);
1766 if (p != NULL) 1766 if (p != NULL)
1767 { 1767 {
1768 if (actext != NULL) 1768 if (actext != NULL)
1769 *actext = vim_strsave(p + 1); 1769 *actext = vim_strsave(p + 1);
1770 text = vim_strnsave(str, (int)(p - str)); 1770 text = vim_strnsave(str, (int)(p - str));
1771 } 1771 }
1772 else 1772 else
1773 text = vim_strsave(str); 1773 text = vim_strsave(str);
1774 1774
1775 /* Find mnemonic characters "&a" and reduce "&&" to "&". */ 1775 // Find mnemonic characters "&a" and reduce "&&" to "&".
1776 for (p = text; p != NULL; ) 1776 for (p = text; p != NULL; )
1777 { 1777 {
1778 p = vim_strchr(p, '&'); 1778 p = vim_strchr(p, '&');
1779 if (p != NULL) 1779 if (p != NULL)
1780 { 1780 {
1781 if (p[1] == NUL) /* trailing "&" */ 1781 if (p[1] == NUL) // trailing "&"
1782 break; 1782 break;
1783 if (mnemonic != NULL && p[1] != '&') 1783 if (mnemonic != NULL && p[1] != '&')
1784 #if !defined(__MVS__) || defined(MOTIF390_MNEMONIC_FIXED) 1784 #if !defined(__MVS__) || defined(MOTIF390_MNEMONIC_FIXED)
1785 *mnemonic = p[1]; 1785 *mnemonic = p[1];
1786 #else 1786 #else
1899 return MENU_INDEX_CMDLINE; 1899 return MENU_INDEX_CMDLINE;
1900 if (finish_op) 1900 if (finish_op)
1901 return MENU_INDEX_OP_PENDING; 1901 return MENU_INDEX_OP_PENDING;
1902 if (State & NORMAL) 1902 if (State & NORMAL)
1903 return MENU_INDEX_NORMAL; 1903 return MENU_INDEX_NORMAL;
1904 if (State & LANGMAP) /* must be a "r" command, like Insert mode */ 1904 if (State & LANGMAP) // must be a "r" command, like Insert mode
1905 return MENU_INDEX_INSERT; 1905 return MENU_INDEX_INSERT;
1906 return MENU_INDEX_INVALID; 1906 return MENU_INDEX_INVALID;
1907 } 1907 }
1908 1908
1909 int 1909 int
1939 1939
1940 for (menu = root_menu; menu != NULL; menu = menu->next) 1940 for (menu = root_menu; menu != NULL; menu = menu->next)
1941 if (STRNCMP("PopUp", menu->name, 5) == 0 && STRNCMP(menu->name + 5, mode, mode_len) == 0) 1941 if (STRNCMP("PopUp", menu->name, 5) == 0 && STRNCMP(menu->name + 5, mode, mode_len) == 0)
1942 break; 1942 break;
1943 1943
1944 /* Only show a popup when it is defined and has entries */ 1944 // Only show a popup when it is defined and has entries
1945 if (menu != NULL && menu->children != NULL) 1945 if (menu != NULL && menu->children != NULL)
1946 { 1946 {
1947 # if defined(FEAT_GUI) 1947 # if defined(FEAT_GUI)
1948 if (gui.in_use) 1948 if (gui.in_use)
1949 { 1949 {
1950 /* Update the menus now, in case the MenuPopup autocommand did 1950 // Update the menus now, in case the MenuPopup autocommand did
1951 * anything. */ 1951 // anything.
1952 gui_update_menus(0); 1952 gui_update_menus(0);
1953 gui_mch_show_popupmenu(menu); 1953 gui_mch_show_popupmenu(menu);
1954 } 1954 }
1955 # endif 1955 # endif
1956 # if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU) 1956 # if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU)
1996 { 1996 {
1997 int idx = 0; 1997 int idx = 0;
1998 1998
1999 while (menu != NULL) 1999 while (menu != NULL)
2000 { 2000 {
2001 /* Don't add a menu when only a tip was defined. */ 2001 // Don't add a menu when only a tip was defined.
2002 if (menu->modes & MENU_ALL_MODES) 2002 if (menu->modes & MENU_ALL_MODES)
2003 { 2003 {
2004 if (menu->children != NULL) 2004 if (menu->children != NULL)
2005 { 2005 {
2006 gui_mch_add_menu(menu, idx); 2006 gui_mch_add_menu(menu, idx);
2031 ) 2031 )
2032 grey = FALSE; 2032 grey = FALSE;
2033 else 2033 else
2034 grey = TRUE; 2034 grey = TRUE;
2035 # ifdef FEAT_GUI_ATHENA 2035 # ifdef FEAT_GUI_ATHENA
2036 /* Hiding menus doesn't work for Athena, it can cause a crash. */ 2036 // Hiding menus doesn't work for Athena, it can cause a crash.
2037 gui_mch_menu_grey(menu, grey); 2037 gui_mch_menu_grey(menu, grey);
2038 # else 2038 # else
2039 /* Never hide a toplevel menu, it may make the menubar resize or 2039 // Never hide a toplevel menu, it may make the menubar resize or
2040 * disappear. Same problem for ToolBar items. */ 2040 // disappear. Same problem for ToolBar items.
2041 if (vim_strchr(p_go, GO_GREY) != NULL || menu->parent == NULL 2041 if (vim_strchr(p_go, GO_GREY) != NULL || menu->parent == NULL
2042 # ifdef FEAT_TOOLBAR 2042 # ifdef FEAT_TOOLBAR
2043 || menu_is_toolbar(menu->parent->name) 2043 || menu_is_toolbar(menu->parent->name)
2044 # endif 2044 # endif
2045 ) 2045 )
2095 || (menu->mnemonic < 256 && TOLOWER_LOC(menu->mnemonic) == key)) 2095 || (menu->mnemonic < 256 && TOLOWER_LOC(menu->mnemonic) == key))
2096 return TRUE; 2096 return TRUE;
2097 return FALSE; 2097 return FALSE;
2098 } 2098 }
2099 # endif 2099 # endif
2100 #endif /* FEAT_GUI */ 2100 #endif // FEAT_GUI
2101 2101
2102 #if (defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)) || defined(PROTO) 2102 #if (defined(FEAT_GUI_MSWIN) && defined(FEAT_TEAROFF)) || defined(PROTO)
2103 2103
2104 /* 2104 /*
2105 * Deal with tearoff items that are added like a menu item. 2105 * Deal with tearoff items that are added like a menu item.
2143 ++pri_idx; 2143 ++pri_idx;
2144 while (menu != NULL) 2144 while (menu != NULL)
2145 { 2145 {
2146 if (menu->children != NULL && menu_is_menubar(menu->name)) 2146 if (menu->children != NULL && menu_is_menubar(menu->name))
2147 { 2147 {
2148 /* Add the menu name to the menu path. Insert a backslash before 2148 // Add the menu name to the menu path. Insert a backslash before
2149 * dots (it's used to separate menu names). */ 2149 // dots (it's used to separate menu names).
2150 len = (int)STRLEN(pname) + (int)STRLEN(menu->name); 2150 len = (int)STRLEN(pname) + (int)STRLEN(menu->name);
2151 for (s = menu->name; *s; ++s) 2151 for (s = menu->name; *s; ++s)
2152 if (*s == '.' || *s == '\\') 2152 if (*s == '.' || *s == '\\')
2153 ++len; 2153 ++len;
2154 newpname = alloc(len + TEAR_LEN + 2); 2154 newpname = alloc(len + TEAR_LEN + 2);
2162 *d++ = '\\'; 2162 *d++ = '\\';
2163 *d++ = *s; 2163 *d++ = *s;
2164 } 2164 }
2165 *d = NUL; 2165 *d = NUL;
2166 2166
2167 /* check if tearoff already exists */ 2167 // check if tearoff already exists
2168 if (STRCMP(menu->children->name, TEAR_STRING) != 0) 2168 if (STRCMP(menu->children->name, TEAR_STRING) != 0)
2169 { 2169 {
2170 gui_add_tearoff(newpname, pri_tab, pri_idx - 1); 2170 gui_add_tearoff(newpname, pri_tab, pri_idx - 1);
2171 *d = NUL; /* remove TEAR_STRING */ 2171 *d = NUL; // remove TEAR_STRING
2172 } 2172 }
2173 2173
2174 STRCAT(newpname, "."); 2174 STRCAT(newpname, ".");
2175 gui_create_tearoffs_recurse(menu->children, newpname, 2175 gui_create_tearoffs_recurse(menu->children, newpname,
2176 pri_tab, pri_idx); 2176 pri_tab, pri_idx);
2202 STRCAT(tbuf + 3, "\r"); 2202 STRCAT(tbuf + 3, "\r");
2203 2203
2204 STRCAT(tearpath, "."); 2204 STRCAT(tearpath, ".");
2205 STRCAT(tearpath, TEAR_STRING); 2205 STRCAT(tearpath, TEAR_STRING);
2206 2206
2207 /* Priority of tear-off is always 1 */ 2207 // Priority of tear-off is always 1
2208 t = pri_tab[pri_idx + 1]; 2208 t = pri_tab[pri_idx + 1];
2209 pri_tab[pri_idx + 1] = 1; 2209 pri_tab[pri_idx + 1] = 1;
2210 2210
2211 #ifdef FEAT_TOOLBAR 2211 #ifdef FEAT_TOOLBAR
2212 menuarg.iconfile = NULL; 2212 menuarg.iconfile = NULL;
2236 { 2236 {
2237 while (menu) 2237 while (menu)
2238 { 2238 {
2239 if (menu->children) 2239 if (menu->children)
2240 { 2240 {
2241 /* check if tearoff exists */ 2241 // check if tearoff exists
2242 if (STRCMP(menu->children->name, TEAR_STRING) == 0) 2242 if (STRCMP(menu->children->name, TEAR_STRING) == 0)
2243 { 2243 {
2244 /* Disconnect the item and free the memory */ 2244 // Disconnect the item and free the memory
2245 free_menu(&menu->children); 2245 free_menu(&menu->children);
2246 } 2246 }
2247 if (menu->children != NULL) /* if not the last one */ 2247 if (menu->children != NULL) // if not the last one
2248 gui_destroy_tearoffs_recurse(menu->children); 2248 gui_destroy_tearoffs_recurse(menu->children);
2249 } 2249 }
2250 menu = menu->next; 2250 menu = menu->next;
2251 } 2251 }
2252 } 2252 }
2253 2253
2254 #endif /* FEAT_GUI_MSWIN && FEAT_TEAROFF */ 2254 #endif // FEAT_GUI_MSWIN && FEAT_TEAROFF
2255 2255
2256 /* 2256 /*
2257 * Execute "menu". Use by ":emenu" and the window toolbar. 2257 * Execute "menu". Use by ":emenu" and the window toolbar.
2258 * "eap" is NULL for the window toolbar. 2258 * "eap" is NULL for the window toolbar.
2259 * "mode_idx" specifies a MENU_INDEX_ value, use -1 to depend on the current 2259 * "mode_idx" specifies a MENU_INDEX_ value, use -1 to depend on the current
2264 { 2264 {
2265 int idx = mode_idx; 2265 int idx = mode_idx;
2266 2266
2267 if (idx < 0) 2267 if (idx < 0)
2268 { 2268 {
2269 /* Use the Insert mode entry when returning to Insert mode. */ 2269 // Use the Insert mode entry when returning to Insert mode.
2270 if (restart_edit 2270 if (restart_edit
2271 #ifdef FEAT_EVAL 2271 #ifdef FEAT_EVAL
2272 && !current_sctx.sc_sid 2272 && !current_sctx.sc_sid
2273 #endif 2273 #endif
2274 ) 2274 )
2289 { 2289 {
2290 pos_T tpos; 2290 pos_T tpos;
2291 2291
2292 idx = MENU_INDEX_VISUAL; 2292 idx = MENU_INDEX_VISUAL;
2293 2293
2294 /* GEDDES: This is not perfect - but it is a 2294 // GEDDES: This is not perfect - but it is a
2295 * quick way of detecting whether we are doing this from a 2295 // quick way of detecting whether we are doing this from a
2296 * selection - see if the range matches up with the visual 2296 // selection - see if the range matches up with the visual
2297 * select start and end. */ 2297 // select start and end.
2298 if ((curbuf->b_visual.vi_start.lnum == eap->line1) 2298 if ((curbuf->b_visual.vi_start.lnum == eap->line1)
2299 && (curbuf->b_visual.vi_end.lnum) == eap->line2) 2299 && (curbuf->b_visual.vi_end.lnum) == eap->line2)
2300 { 2300 {
2301 /* Set it up for visual mode - equivalent to gv. */ 2301 // Set it up for visual mode - equivalent to gv.
2302 VIsual_mode = curbuf->b_visual.vi_mode; 2302 VIsual_mode = curbuf->b_visual.vi_mode;
2303 tpos = curbuf->b_visual.vi_end; 2303 tpos = curbuf->b_visual.vi_end;
2304 curwin->w_cursor = curbuf->b_visual.vi_start; 2304 curwin->w_cursor = curbuf->b_visual.vi_start;
2305 curwin->w_curswant = curbuf->b_visual.vi_curswant; 2305 curwin->w_curswant = curbuf->b_visual.vi_curswant;
2306 } 2306 }
2307 else 2307 else
2308 { 2308 {
2309 /* Set it up for line-wise visual mode */ 2309 // Set it up for line-wise visual mode
2310 VIsual_mode = 'V'; 2310 VIsual_mode = 'V';
2311 curwin->w_cursor.lnum = eap->line1; 2311 curwin->w_cursor.lnum = eap->line1;
2312 curwin->w_cursor.col = 1; 2312 curwin->w_cursor.col = 1;
2313 tpos.lnum = eap->line2; 2313 tpos.lnum = eap->line2;
2314 tpos.col = MAXCOL; 2314 tpos.col = MAXCOL;
2315 tpos.coladd = 0; 2315 tpos.coladd = 0;
2316 } 2316 }
2317 2317
2318 /* Activate visual mode */ 2318 // Activate visual mode
2319 VIsual_active = TRUE; 2319 VIsual_active = TRUE;
2320 VIsual_reselect = TRUE; 2320 VIsual_reselect = TRUE;
2321 check_cursor(); 2321 check_cursor();
2322 VIsual = curwin->w_cursor; 2322 VIsual = curwin->w_cursor;
2323 curwin->w_cursor = tpos; 2323 curwin->w_cursor = tpos;
2324 2324
2325 check_cursor(); 2325 check_cursor();
2326 2326
2327 /* Adjust the cursor to make sure it is in the correct pos 2327 // Adjust the cursor to make sure it is in the correct pos
2328 * for exclusive mode */ 2328 // for exclusive mode
2329 if (*p_sel == 'e' && gchar_cursor() != NUL) 2329 if (*p_sel == 'e' && gchar_cursor() != NUL)
2330 ++curwin->w_cursor.col; 2330 ++curwin->w_cursor.col;
2331 } 2331 }
2332 } 2332 }
2333 2333
2334 /* For the WinBar menu always use the Normal mode menu. */ 2334 // For the WinBar menu always use the Normal mode menu.
2335 if (idx == -1 || eap == NULL) 2335 if (idx == -1 || eap == NULL)
2336 idx = MENU_INDEX_NORMAL; 2336 idx = MENU_INDEX_NORMAL;
2337 2337
2338 if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL 2338 if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL
2339 && (menu->modes & (1 << idx))) 2339 && (menu->modes & (1 << idx)))
2340 { 2340 {
2341 /* When executing a script or function execute the commands right now. 2341 // When executing a script or function execute the commands right now.
2342 * Also for the window toolbar. 2342 // Also for the window toolbar.
2343 * Otherwise put them in the typeahead buffer. */ 2343 // Otherwise put them in the typeahead buffer.
2344 if (eap == NULL 2344 if (eap == NULL
2345 #ifdef FEAT_EVAL 2345 #ifdef FEAT_EVAL
2346 || current_sctx.sc_sid != 0 2346 || current_sctx.sc_sid != 0
2347 #endif 2347 #endif
2348 ) 2348 )
2430 2430
2431 menu = *get_root_menu(saved_name); 2431 menu = *get_root_menu(saved_name);
2432 name = saved_name; 2432 name = saved_name;
2433 while (*name) 2433 while (*name)
2434 { 2434 {
2435 /* Find in the menu hierarchy */ 2435 // Find in the menu hierarchy
2436 p = menu_name_skip(name); 2436 p = menu_name_skip(name);
2437 2437
2438 while (menu != NULL) 2438 while (menu != NULL)
2439 { 2439 {
2440 if (menu_name_equal(name, menu)) 2440 if (menu_name_equal(name, menu))
2494 int save_visual_reselect = VIsual_reselect; 2494 int save_visual_reselect = VIsual_reselect;
2495 int save_visual_mode = VIsual_mode; 2495 int save_visual_mode = VIsual_mode;
2496 2496
2497 if (wp != curwin) 2497 if (wp != curwin)
2498 { 2498 {
2499 /* Clicking in the window toolbar of a not-current window. 2499 // Clicking in the window toolbar of a not-current window.
2500 * Make that window the current one and save Visual mode. */ 2500 // Make that window the current one and save Visual mode.
2501 save_curwin = curwin; 2501 save_curwin = curwin;
2502 VIsual_active = FALSE; 2502 VIsual_active = FALSE;
2503 curwin = wp; 2503 curwin = wp;
2504 curbuf = curwin->w_buffer; 2504 curbuf = curwin->w_buffer;
2505 check_cursor(); 2505 check_cursor();
2545 return NULL; 2545 return NULL;
2546 2546
2547 name = saved_name; 2547 name = saved_name;
2548 while (*name) 2548 while (*name)
2549 { 2549 {
2550 /* find the end of one dot-separated name and put a NUL at the dot */ 2550 // find the end of one dot-separated name and put a NUL at the dot
2551 p = menu_name_skip(name); 2551 p = menu_name_skip(name);
2552 2552
2553 while (menu != NULL) 2553 while (menu != NULL)
2554 { 2554 {
2555 if (menu_name_equal(name, menu)) 2555 if (menu_name_equal(name, menu))
2556 { 2556 {
2557 if (menu->children == NULL) 2557 if (menu->children == NULL)
2558 { 2558 {
2559 /* found a menu item instead of a sub-menu */ 2559 // found a menu item instead of a sub-menu
2560 if (*p == NUL) 2560 if (*p == NUL)
2561 emsg(_("E336: Menu path must lead to a sub-menu")); 2561 emsg(_("E336: Menu path must lead to a sub-menu"));
2562 else 2562 else
2563 emsg(_(e_notsubmenu)); 2563 emsg(_(e_notsubmenu));
2564 menu = NULL; 2564 menu = NULL;
2565 goto theend; 2565 goto theend;
2566 } 2566 }
2567 if (*p == NUL) /* found a full match */ 2567 if (*p == NUL) // found a full match
2568 goto theend; 2568 goto theend;
2569 break; 2569 break;
2570 } 2570 }
2571 menu = menu->next; 2571 menu = menu->next;
2572 } 2572 }
2573 if (menu == NULL) /* didn't find it */ 2573 if (menu == NULL) // didn't find it
2574 break; 2574 break;
2575 2575
2576 /* Found a match, search the sub-menu. */ 2576 // Found a match, search the sub-menu.
2577 menu = menu->children; 2577 menu = menu->children;
2578 name = p; 2578 name = p;
2579 } 2579 }
2580 2580
2581 if (menu == NULL) 2581 if (menu == NULL)
2591 * Translation of menu names. Just a simple lookup table. 2591 * Translation of menu names. Just a simple lookup table.
2592 */ 2592 */
2593 2593
2594 typedef struct 2594 typedef struct
2595 { 2595 {
2596 char_u *from; /* English name */ 2596 char_u *from; // English name
2597 char_u *from_noamp; /* same, without '&' */ 2597 char_u *from_noamp; // same, without '&'
2598 char_u *to; /* translated name */ 2598 char_u *to; // translated name
2599 } menutrans_T; 2599 } menutrans_T;
2600 2600
2601 static garray_T menutrans_ga = {0, 0, 0, 0, NULL}; 2601 static garray_T menutrans_ga = {0, 0, 0, 0, NULL};
2602 #endif 2602 #endif
2603 2603
2630 vim_free(tp[i].from_noamp); 2630 vim_free(tp[i].from_noamp);
2631 vim_free(tp[i].to); 2631 vim_free(tp[i].to);
2632 } 2632 }
2633 ga_clear(&menutrans_ga); 2633 ga_clear(&menutrans_ga);
2634 # ifdef FEAT_EVAL 2634 # ifdef FEAT_EVAL
2635 /* Delete all "menutrans_" global variables. */ 2635 // Delete all "menutrans_" global variables.
2636 del_menutrans_vars(); 2636 del_menutrans_vars();
2637 # endif 2637 # endif
2638 } 2638 }
2639 else 2639 else
2640 { 2640 {
2641 /* ":menutrans from to": add translation */ 2641 // ":menutrans from to": add translation
2642 from = arg; 2642 from = arg;
2643 arg = menu_skip_part(arg); 2643 arg = menu_skip_part(arg);
2644 to = skipwhite(arg); 2644 to = skipwhite(arg);
2645 *arg = NUL; 2645 *arg = NUL;
2646 arg = menu_skip_part(to); 2646 arg = menu_skip_part(to);
2711 2711
2712 for (i = 0; i < menutrans_ga.ga_len; ++i) 2712 for (i = 0; i < menutrans_ga.ga_len; ++i)
2713 if (STRNICMP(name, tp[i].from, len) == 0 && tp[i].from[len] == NUL) 2713 if (STRNICMP(name, tp[i].from, len) == 0 && tp[i].from[len] == NUL)
2714 return tp[i].to; 2714 return tp[i].to;
2715 2715
2716 /* Now try again while ignoring '&' characters. */ 2716 // Now try again while ignoring '&' characters.
2717 i = name[len]; 2717 i = name[len];
2718 name[len] = NUL; 2718 name[len] = NUL;
2719 dname = menu_text(name, NULL, NULL); 2719 dname = menu_text(name, NULL, NULL);
2720 name[len] = i; 2720 name[len] = i;
2721 if (dname != NULL) 2721 if (dname != NULL)
2742 2742
2743 for (p = name; *p && *p != '.'; MB_PTR_ADV(p)) 2743 for (p = name; *p && *p != '.'; MB_PTR_ADV(p))
2744 if (*p == '\\') 2744 if (*p == '\\')
2745 STRMOVE(p, p + 1); 2745 STRMOVE(p, p + 1);
2746 } 2746 }
2747 #endif /* FEAT_MULTI_LANG */ 2747 #endif // FEAT_MULTI_LANG
2748 2748
2749 /* 2749 /*
2750 * Isolate the menu name. 2750 * Isolate the menu name.
2751 * Skip the menu name, and translate <Tab> into a real TAB. 2751 * Skip the menu name, and translate <Tab> into a real TAB.
2752 */ 2752 */
2771 arg = skipwhite(arg); 2771 arg = skipwhite(arg);
2772 2772
2773 return arg; 2773 return arg;
2774 } 2774 }
2775 2775
2776 #endif /* FEAT_MENU */ 2776 #endif // FEAT_MENU