comparison src/menu.c @ 26909:aa65d1808bd0 v8.2.3983

patch 8.2.3983: error messages are spread out Commit: https://github.com/vim/vim/commit/eaaac014a01ce37c1f86dbda054c01a5c6f034e7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 2 17:00:40 2022 +0000 patch 8.2.3983: error messages are spread out Problem: Error messages are spread out. Solution: Move more error messages to errors.h.
author Bram Moolenaar <Bram@vim.org>
date Sun, 02 Jan 2022 18:15:04 +0100
parents 612339679616
children 51ddf6740ac6
comparison
equal deleted inserted replaced
26908:006aa45685f9 26909:aa65d1808bd0
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
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\"");
64 61
65 #ifdef FEAT_TOOLBAR 62 #ifdef FEAT_TOOLBAR
66 static const char *toolbar_names[] = 63 static const char *toolbar_names[] =
67 { 64 {
68 /* 0 */ "New", "Open", "Save", "Undo", "Redo", 65 /* 0 */ "New", "Open", "Save", "Undo", "Redo",
531 if (menu_name_equal(name, menu) || menu_name_equal(dname, menu)) 528 if (menu_name_equal(name, menu) || menu_name_equal(dname, menu))
532 { 529 {
533 if (*next_name == NUL && menu->children != NULL) 530 if (*next_name == NUL && menu->children != NULL)
534 { 531 {
535 if (!sys_menu) 532 if (!sys_menu)
536 emsg(_("E330: Menu path must not lead to a sub-menu")); 533 emsg(_(e_menu_path_must_not_loead_to_sub_menu));
537 goto erret; 534 goto erret;
538 } 535 }
539 if (*next_name != NUL && menu->children == NULL 536 if (*next_name != NUL && menu->children == NULL
540 #ifdef FEAT_GUI_MSWIN 537 #ifdef FEAT_GUI_MSWIN
541 && addtearoff 538 && addtearoff
542 #endif 539 #endif
543 ) 540 )
544 { 541 {
545 if (!sys_menu) 542 if (!sys_menu)
546 emsg(_(e_notsubmenu)); 543 emsg(_(e_part_of_menu_item_path_is_not_sub_menu));
547 goto erret; 544 goto erret;
548 } 545 }
549 break; 546 break;
550 } 547 }
551 menup = &menu->next; 548 menup = &menu->next;
570 567
571 if (menu == NULL) 568 if (menu == NULL)
572 { 569 {
573 if (*next_name == NUL && parent == NULL) 570 if (*next_name == NUL && parent == NULL)
574 { 571 {
575 emsg(_("E331: Must not add menu items directly to menu bar")); 572 emsg(_(e_must_not_add_menu_items_directly_to_menu_bar));
576 goto erret; 573 goto erret;
577 } 574 }
578 575
579 if (menu_is_separator(dname) && *next_name != NUL) 576 if (menu_is_separator(dname) && *next_name != NUL)
580 { 577 {
581 emsg(_("E332: Separator cannot be part of a menu path")); 578 emsg(_(e_separator_cannot_be_part_of_menu_path));
582 goto erret; 579 goto erret;
583 } 580 }
584 581
585 // Not already there, so let's add it 582 // Not already there, so let's add it
586 menu = ALLOC_CLEAR_ONE(vimmenu_T); 583 menu = ALLOC_CLEAR_ONE(vimmenu_T);
869 { 866 {
870 if (*p != NUL) 867 if (*p != NUL)
871 { 868 {
872 if (menu->children == NULL) 869 if (menu->children == NULL)
873 { 870 {
874 emsg(_(e_notsubmenu)); 871 emsg(_(e_part_of_menu_item_path_is_not_sub_menu));
875 return FAIL; 872 return FAIL;
876 } 873 }
877 if (menu_nable_recurse(menu->children, p, modes, enable) 874 if (menu_nable_recurse(menu->children, p, modes, enable)
878 == FAIL) 875 == FAIL)
879 return FAIL; 876 return FAIL;
894 } 891 }
895 menu = menu->next; 892 menu = menu->next;
896 } 893 }
897 if (*name != NUL && *name != '*' && menu == NULL) 894 if (*name != NUL && *name != '*' && menu == NULL)
898 { 895 {
899 semsg(_(e_nomenu), name); 896 semsg(_(e_no_menu_str), name);
900 return FAIL; 897 return FAIL;
901 } 898 }
902 899
903 #ifdef FEAT_GUI 900 #ifdef FEAT_GUI
904 // Want to update menus now even if mode not changed 901 // Want to update menus now even if mode not changed
935 if (*name == NUL || menu_name_equal(name, menu)) 932 if (*name == NUL || menu_name_equal(name, menu))
936 { 933 {
937 if (*p != NUL && menu->children == NULL) 934 if (*p != NUL && menu->children == NULL)
938 { 935 {
939 if (!silent) 936 if (!silent)
940 emsg(_(e_notsubmenu)); 937 emsg(_(e_part_of_menu_item_path_is_not_sub_menu));
941 return FAIL; 938 return FAIL;
942 } 939 }
943 if ((menu->modes & modes) != 0x0) 940 if ((menu->modes & modes) != 0x0)
944 { 941 {
945 #if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF) 942 #if defined(FEAT_GUI_MSWIN) & defined(FEAT_TEAROFF)
987 if (*name != NUL) 984 if (*name != NUL)
988 { 985 {
989 if (menu == NULL) 986 if (menu == NULL)
990 { 987 {
991 if (!silent) 988 if (!silent)
992 semsg(_(e_nomenu), name); 989 semsg(_(e_no_menu_str), name);
993 return FAIL; 990 return FAIL;
994 } 991 }
995 992
996 993
997 // Recalculate modes for menu based on the new updated children 994 // Recalculate modes for menu based on the new updated children
1125 if (menu_name_equal(name, menu)) 1122 if (menu_name_equal(name, menu))
1126 { 1123 {
1127 // Found menu 1124 // Found menu
1128 if (*p != NUL && menu->children == NULL) 1125 if (*p != NUL && menu->children == NULL)
1129 { 1126 {
1130 emsg(_(e_notsubmenu)); 1127 emsg(_(e_part_of_menu_item_path_is_not_sub_menu));
1131 vim_free(path_name); 1128 vim_free(path_name);
1132 return FAIL; 1129 return FAIL;
1133 } 1130 }
1134 else if ((menu->modes & modes) == 0x0) 1131 else if ((menu->modes & modes) == 0x0)
1135 { 1132 {
1141 } 1138 }
1142 menu = menu->next; 1139 menu = menu->next;
1143 } 1140 }
1144 if (menu == NULL) 1141 if (menu == NULL)
1145 { 1142 {
1146 semsg(_(e_nomenu), name); 1143 semsg(_(e_no_menu_str), name);
1147 vim_free(path_name); 1144 vim_free(path_name);
1148 return FAIL; 1145 return FAIL;
1149 } 1146 }
1150 name = p; 1147 name = p;
1151 parent = menu; 1148 parent = menu;
2421 break; 2418 break;
2422 // case MENU_INDEX_TIP: cannot happen 2419 // case MENU_INDEX_TIP: cannot happen
2423 default: 2420 default:
2424 mode = (char_u *)"Normal"; 2421 mode = (char_u *)"Normal";
2425 } 2422 }
2426 semsg(_("E335: Menu not defined for %s mode"), mode); 2423 semsg(_(e_menu_not_defined_for_str_mode), mode);
2427 } 2424 }
2428 } 2425 }
2429 2426
2430 /* 2427 /*
2431 * Lookup a menu by the descriptor name e.g. "File.New" 2428 * Lookup a menu by the descriptor name e.g. "File.New"
2455 { 2452 {
2456 if (menu_name_equal(name, menu)) 2453 if (menu_name_equal(name, menu))
2457 { 2454 {
2458 if (*p == NUL && menu->children != NULL) 2455 if (*p == NUL && menu->children != NULL)
2459 { 2456 {
2460 emsg(_("E333: Menu path must lead to a menu item")); 2457 emsg(_(e_menu_path_must_lead_to_menu_item));
2461 gave_emsg = TRUE; 2458 gave_emsg = TRUE;
2462 menu = NULL; 2459 menu = NULL;
2463 } 2460 }
2464 else if (*p != NUL && menu->children == NULL) 2461 else if (*p != NUL && menu->children == NULL)
2465 { 2462 {
2466 emsg(_(e_notsubmenu)); 2463 emsg(_(e_part_of_menu_item_path_is_not_sub_menu));
2467 menu = NULL; 2464 menu = NULL;
2468 } 2465 }
2469 break; 2466 break;
2470 } 2467 }
2471 menu = menu->next; 2468 menu = menu->next;
2477 } 2474 }
2478 vim_free(saved_name); 2475 vim_free(saved_name);
2479 if (menu == NULL) 2476 if (menu == NULL)
2480 { 2477 {
2481 if (!gave_emsg) 2478 if (!gave_emsg)
2482 semsg(_("E334: Menu not found: %s"), name_arg); 2479 semsg(_(e_menu_not_found_str), name_arg);
2483 return NULL; 2480 return NULL;
2484 } 2481 }
2485 2482
2486 return menu; 2483 return menu;
2487 } 2484 }
2607 { 2604 {
2608 if (menu->children == NULL) 2605 if (menu->children == NULL)
2609 { 2606 {
2610 // found a menu item instead of a sub-menu 2607 // found a menu item instead of a sub-menu
2611 if (*p == NUL) 2608 if (*p == NUL)
2612 emsg(_("E336: Menu path must lead to a sub-menu")); 2609 emsg(_(e_menu_path_must_lead_to_sub_menu));
2613 else 2610 else
2614 emsg(_(e_notsubmenu)); 2611 emsg(_(e_part_of_menu_item_path_is_not_sub_menu));
2615 menu = NULL; 2612 menu = NULL;
2616 goto theend; 2613 goto theend;
2617 } 2614 }
2618 if (*p == NUL) // found a full match 2615 if (*p == NUL) // found a full match
2619 goto theend; 2616 goto theend;
2628 menu = menu->children; 2625 menu = menu->children;
2629 name = p; 2626 name = p;
2630 } 2627 }
2631 2628
2632 if (menu == NULL) 2629 if (menu == NULL)
2633 emsg(_("E337: Menu not found - check menu names")); 2630 emsg(_(e_menu_not_found_check_menu_names));
2634 theend: 2631 theend:
2635 vim_free(saved_name); 2632 vim_free(saved_name);
2636 return menu; 2633 return menu;
2637 } 2634 }
2638 #endif 2635 #endif