annotate src/menu.c @ 9725:4a4a71d67131 v7.4.2138

commit https://github.com/vim/vim/commit/2d3d60a7d4b410668dfc427120205ccf88789db4 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 1 16:27:23 2016 +0200 patch 7.4.2138 Problem: Test 86 and 87 fail. Solution: Call func_ref() also for regular functions.
author Christian Brabandt <cb@256bit.org>
date Mon, 01 Aug 2016 16:30:06 +0200
parents b2aada04d84e
children 4aead6a9b7a9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * GUI/Motif support by Robert Webb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * Code for menus. Used for the GUI and 'wildmenu'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 #if defined(FEAT_MENU) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 #define MENUDEPTH 10 /* maximum depth of menus */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 #ifdef FEAT_GUI_W32
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
22 static int add_menu_path(char_u *, vimmenu_T *, int *, char_u *, int);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 #else
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
24 static int add_menu_path(char_u *, vimmenu_T *, int *, char_u *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 #endif
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
26 static int menu_nable_recurse(vimmenu_T *menu, char_u *name, int modes, int enable);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
27 static int remove_menu(vimmenu_T **, char_u *, int, int silent);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
28 static void free_menu(vimmenu_T **menup);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
29 static void free_menu_string(vimmenu_T *, int);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
30 static int show_menus(char_u *, int);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
31 static void show_menus_recursive(vimmenu_T *, int, int);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
32 static int menu_name_equal(char_u *name, vimmenu_T *menu);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
33 static int menu_namecmp(char_u *name, char_u *mname);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
34 static int get_menu_cmd_modes(char_u *, int, int *, int *);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
35 static char_u *popup_mode_name(char_u *name, int idx);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
36 static char_u *menu_text(char_u *text, int *mnemonic, char_u **actext);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #ifdef FEAT_GUI
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
38 static int get_menu_mode(void);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
39 static void gui_update_menus_recurse(vimmenu_T *, int);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 #if defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
43 static void gui_create_tearoffs_recurse(vimmenu_T *menu, const char_u *pname, int *pri_tab, int pri_idx);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
44 static void gui_add_tearoff(char_u *tearpath, int *pri_tab, int pri_idx);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
45 static void gui_destroy_tearoffs_recurse(vimmenu_T *menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 static int s_tearoffs = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
49 static int menu_is_hidden(char_u *name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 #if defined(FEAT_CMDL_COMPL) || (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF))
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
51 static int menu_is_tearoff(char_u *name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 #if defined(FEAT_MULTI_LANG) || defined(FEAT_TOOLBAR)
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
55 static char_u *menu_skip_part(char_u *p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 #ifdef FEAT_MULTI_LANG
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
58 static char_u *menutrans_lookup(char_u *name, int len);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
59 static void menu_unescape_name(char_u *p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 5735
diff changeset
62 static char_u *menu_translate_tab_and_shift(char_u *arg_start);
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
63
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 /* The character for each menu mode */
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 838
diff changeset
65 static char_u menu_mode_chars[] = {'n', 'v', 's', 'o', 'i', 'c', 't'};
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 static char_u e_othermode[] = N_("E328: Menu only exists in another mode");
436
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
69 static char_u e_nomenu[] = N_("E329: No menu \"%s\"");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 static const char *toolbar_names[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 /* 0 */ "New", "Open", "Save", "Undo", "Redo",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 /* 5 */ "Cut", "Copy", "Paste", "Print", "Help",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 /* 10 */ "Find", "SaveAll", "SaveSesn", "NewSesn", "LoadSesn",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 /* 15 */ "RunScript", "Replace", "WinClose", "WinMax", "WinMin",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 /* 20 */ "WinSplit", "Shell", "FindPrev", "FindNext", "FindHelp",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 /* 25 */ "Make", "TagJump", "RunCtags", "WinVSplit", "WinMaxWidth",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 /* 30 */ "WinMinWidth", "Exit"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 # define TOOLBAR_NAME_COUNT (sizeof(toolbar_names) / sizeof(char *))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 * Do the :menu command and relatives.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
89 ex_menu(
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
90 exarg_T *eap) /* Ex command arguments */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 char_u *menu_path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 int modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 char_u *map_to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 int noremap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 int silent = FALSE;
860
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 856
diff changeset
97 int special = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 int unmenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 char_u *map_buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 char_u *arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 int i;
575
f1d46f948241 updated for version 7.0163
vimboss
parents: 533
diff changeset
103 #if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 int old_menu_height;
8163
d8a8e86f39ad commit https://github.com/vim/vim/commit/e89ff0472bc33779583d48e8d38a5e794d05613a
Christian Brabandt <cb@256bit.org>
parents: 7827
diff changeset
105 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 int old_toolbar_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 int pri_tab[MENUDEPTH + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 * disable */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 char_u *icon = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 vimmenu_T menuarg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 modes = get_menu_cmd_modes(eap->cmd, eap->forceit, &noremap, &unmenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 if (STRNCMP(arg, "<script>", 8) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 noremap = REMAP_SCRIPT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 arg = skipwhite(arg + 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 if (STRNCMP(arg, "<silent>", 8) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 silent = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 arg = skipwhite(arg + 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 }
860
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 856
diff changeset
134 if (STRNCMP(arg, "<special>", 9) == 0)
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 856
diff changeset
135 {
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 856
diff changeset
136 special = TRUE;
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 856
diff changeset
137 arg = skipwhite(arg + 9);
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 856
diff changeset
138 continue;
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 856
diff changeset
139 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 /* Locate an optional "icon=filename" argument. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 if (STRNCMP(arg, "icon=", 5) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 arg += 5;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 icon = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 while (*arg != NUL && *arg != ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 if (*arg == '\\')
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1050
diff changeset
154 STRMOVE(arg, arg + 1);
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
155 mb_ptr_adv(arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 if (*arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 *arg++ = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 * Fill in the priority table.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 for (p = arg; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 if (!VIM_ISDIGIT(*p) && *p != '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 if (vim_iswhite(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 for (i = 0; i < MENUDEPTH && !vim_iswhite(*arg); ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 pri_tab[i] = getdigits(&arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 if (pri_tab[i] == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 pri_tab[i] = 500;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 if (*arg == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 ++arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 else if (eap->addr_count && eap->line2 != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 pri_tab[0] = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 i = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 while (i < MENUDEPTH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 pri_tab[i++] = 500;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 pri_tab[MENUDEPTH] = -1; /* mark end of the table */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 * Check for "disable" or "enable" argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 if (STRNCMP(arg, "enable", 6) == 0 && vim_iswhite(arg[6]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 enable = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 arg = skipwhite(arg + 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 else if (STRNCMP(arg, "disable", 7) == 0 && vim_iswhite(arg[7]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 enable = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 arg = skipwhite(arg + 7);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 * If there is no argument, display all menus.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 if (*arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 show_menus(arg, modes);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 * Need to get the toolbar icon index before doing the translation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 menuarg.iconidx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 menuarg.icon_builtin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 if (menu_is_toolbar(arg))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 menu_path = menu_skip_part(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 if (*menu_path == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 p = menu_skip_part(++menu_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 if (STRNCMP(menu_path, "BuiltIn", 7) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 if (skipdigits(menu_path + 7) == p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 menuarg.iconidx = atoi((char *)menu_path + 7);
1880
e5602d92da8c updated for version 7.2-177
vimboss
parents: 1704
diff changeset
233 if (menuarg.iconidx >= (int)TOOLBAR_NAME_COUNT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 menuarg.iconidx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 menuarg.icon_builtin = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 {
1880
e5602d92da8c updated for version 7.2-177
vimboss
parents: 1704
diff changeset
241 for (i = 0; i < (int)TOOLBAR_NAME_COUNT; ++i)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 if (STRNCMP(toolbar_names[i], menu_path, p - menu_path)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 menuarg.iconidx = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 menu_path = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 if (*menu_path == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 EMSG2(_(e_invarg2), menu_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
260 map_to = menu_translate_tab_and_shift(arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 * If there is only a menu name, display menus with that name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 if (*map_to == NUL && !unmenu && enable == MAYBE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 show_menus(menu_path, modes);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 else if (*map_to != NUL && (unmenu || enable != MAYBE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 EMSG(_(e_trailing));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 }
575
f1d46f948241 updated for version 7.0163
vimboss
parents: 533
diff changeset
275 #if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 old_menu_height = gui.menu_height;
8163
d8a8e86f39ad commit https://github.com/vim/vim/commit/e89ff0472bc33779583d48e8d38a5e794d05613a
Christian Brabandt <cb@256bit.org>
parents: 7827
diff changeset
277 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 old_toolbar_height = gui.toolbar_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 if (enable != MAYBE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 * Change sensitivity of the menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 * For the PopUp menu, remove a menu for each mode separately.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 * Careful: menu_nable_recurse() changes menu_path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 if (STRCMP(menu_path, "*") == 0) /* meaning: do all menus */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 menu_path = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 if (menu_is_popup(menu_path))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 for (i = 0; i < MENU_INDEX_TIP; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 if (modes & (1 << i))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 p = popup_mode_name(menu_path, i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 menu_nable_recurse(root_menu, p, MENU_ALL_MODES,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 enable);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 menu_nable_recurse(root_menu, menu_path, modes, enable);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 else if (unmenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 * Delete menu(s).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 if (STRCMP(menu_path, "*") == 0) /* meaning: remove all menus */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 menu_path = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 * For the PopUp menu, remove a menu for each mode separately.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 if (menu_is_popup(menu_path))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 for (i = 0; i < MENU_INDEX_TIP; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 if (modes & (1 << i))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 p = popup_mode_name(menu_path, i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 remove_menu(&root_menu, p, MENU_ALL_MODES, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 /* Careful: remove_menu() changes menu_path */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 remove_menu(&root_menu, menu_path, modes, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 * Add menu(s).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 * Replace special key codes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 if (STRICMP(map_to, "<nop>") == 0) /* "<Nop>" means nothing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 map_to = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 map_buf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 }
26
404aac550f35 updated for version 7.0017
vimboss
parents: 11
diff changeset
347 else if (modes & MENU_TIP_MODE)
404aac550f35 updated for version 7.0017
vimboss
parents: 11
diff changeset
348 map_buf = NULL; /* Menu tips are plain text. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 else
860
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 856
diff changeset
350 map_to = replace_termcodes(map_to, &map_buf, FALSE, TRUE, special);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 menuarg.modes = modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 menuarg.iconfile = icon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 menuarg.noremap[0] = noremap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 menuarg.silent[0] = silent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 add_menu_path(menu_path, &menuarg, pri_tab, map_to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 #ifdef FEAT_GUI_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 , TRUE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 * For the PopUp menu, add a menu for each mode separately.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 if (menu_is_popup(menu_path))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 for (i = 0; i < MENU_INDEX_TIP; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 if (modes & (1 << i))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 p = popup_mode_name(menu_path, i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 /* Include all modes, to make ":amenu" work */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 menuarg.modes = modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 menuarg.iconfile = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 menuarg.iconidx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 menuarg.icon_builtin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 add_menu_path(p, &menuarg, pri_tab, map_to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 #ifdef FEAT_GUI_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 , TRUE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 vim_free(map_buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393
575
f1d46f948241 updated for version 7.0163
vimboss
parents: 533
diff changeset
394 #if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 /* If the menubar height changed, resize the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 if (gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 && (gui.menu_height != old_menu_height
8163
d8a8e86f39ad commit https://github.com/vim/vim/commit/e89ff0472bc33779583d48e8d38a5e794d05613a
Christian Brabandt <cb@256bit.org>
parents: 7827
diff changeset
398 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 || gui.toolbar_height != old_toolbar_height
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 ))
814
f40f1a8520ff updated for version 7.0c01
vimboss
parents: 791
diff changeset
402 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 theend:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 * Add the menu with the given name to the menu hierarchy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
413 add_menu_path(
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
414 char_u *menu_path,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
415 vimmenu_T *menuarg, /* passes modes, iconfile, iconidx,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
416 icon_builtin, silent[0], noremap[0] */
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
417 int *pri_tab,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
418 char_u *call_data
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 #ifdef FEAT_GUI_W32
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
420 , int addtearoff /* may add tearoff item */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 #endif
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
422 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 char_u *path_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 int modes = menuarg->modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 vimmenu_T **menup;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 vimmenu_T *menu = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 vimmenu_T *parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 vimmenu_T **lower_pri;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 char_u *dname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 char_u *next_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 int c;
2149
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
436 int d;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 int new_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 int pri_idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 int old_modes = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 int amenu;
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
444 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
445 char_u *en_name;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
446 char_u *map_to = NULL;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
447 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 /* Make a copy so we can stuff around with it, since it could be const */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 path_name = vim_strsave(menu_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 if (path_name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 menup = &root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 parent = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 name = path_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 while (*name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 /* Get name of this element in the menu hierarchy, and the simplified
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 * name (without mnemonic and accelerator text). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 next_name = menu_name_skip(name);
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
461 #ifdef FEAT_MULTI_LANG
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 2166
diff changeset
462 map_to = menutrans_lookup(name, (int)STRLEN(name));
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
463 if (map_to != NULL)
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
464 {
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
465 en_name = name;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
466 name = map_to;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
467 }
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
468 else
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
469 en_name = NULL;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
470 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 dname = menu_text(name, NULL, NULL);
928
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
472 if (dname == NULL)
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
473 goto erret;
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
474 if (*dname == NUL)
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
475 {
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
476 /* Only a mnemonic or accelerator is not valid. */
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
477 EMSG(_("E792: Empty menu name"));
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
478 goto erret;
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
479 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 /* See if it's already there */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 lower_pri = menup;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 new_idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 menu = *menup;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 while (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 if (menu_name_equal(name, menu) || menu_name_equal(dname, menu))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 if (*next_name == NUL && menu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 if (!sys_menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 EMSG(_("E330: Menu path must not lead to a sub-menu"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 goto erret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 if (*next_name != NUL && menu->children == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 #ifdef FEAT_GUI_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 && addtearoff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 if (!sys_menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 EMSG(_(e_notsubmenu));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 goto erret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 menup = &menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 /* Count menus, to find where this one needs to be inserted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 * Ignore menus that are not in the menubar (PopUp and Toolbar) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 if (parent != NULL || menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 ++idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 if (menu->priority <= pri_tab[pri_idx])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 lower_pri = menup;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 new_idx = idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 if (menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 if (*next_name == NUL && parent == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 EMSG(_("E331: Must not add menu items directly to menu bar"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 goto erret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 if (menu_is_separator(dname) && *next_name != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 EMSG(_("E332: Separator cannot be part of a menu path"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 goto erret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 /* Not already there, so lets add it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 menu = (vimmenu_T *)alloc_clear((unsigned)sizeof(vimmenu_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 if (menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 goto erret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 menu->modes = modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 menu->enabled = MENU_ALL_MODES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 menu->name = vim_strsave(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 /* separate mnemonic and accelerator text from actual menu name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 menu->dname = menu_text(name, &menu->mnemonic, &menu->actext);
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
554 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
555 if (en_name != NULL)
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
556 {
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
557 menu->en_name = vim_strsave(en_name);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
558 menu->en_dname = menu_text(en_name, NULL, NULL);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
559 }
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
560 else
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
561 {
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
562 menu->en_name = NULL;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
563 menu->en_dname = NULL;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
564 }
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
565 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 menu->priority = pri_tab[pri_idx];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 menu->parent = parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 #ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 menu->sensitive = TRUE; /* the default */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 #ifdef FEAT_BEVAL_TIP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 menu->tip = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 #ifdef FEAT_GUI_ATHENA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 menu->image = None; /* X-Windows definition for NULL*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 * Add after menu that has lower priority.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 menu->next = *lower_pri;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 *lower_pri = menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 old_modes = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 menu->iconidx = menuarg->iconidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 menu->icon_builtin = menuarg->icon_builtin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 if (*next_name == NUL && menuarg->iconfile != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 menu->iconfile = vim_strsave(menuarg->iconfile);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 #if defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 /* the tearoff item must be present in the modes of each item. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 if (parent != NULL && menu_is_tearoff(parent->children->dname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 parent->children->modes |= modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 old_modes = menu->modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 * If this menu option was previously only available in other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 * modes, then make sure it's available for this one now
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 * Also enable a menu when it's created or changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 #ifdef FEAT_GUI_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 /* If adding a tearbar (addtearoff == FALSE) don't update modes */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 if (addtearoff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 menu->modes |= modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 menu->enabled |= modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 * Add the menu item when it's used in one of the modes, but not when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 * only a tooltip is defined.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 if ((old_modes & MENU_ALL_MODES) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 && (menu->modes & MENU_ALL_MODES) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 if (gui.in_use) /* Otherwise it will be added when GUI starts */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 if (*next_name == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 /* Real menu item, not sub-menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 gui_mch_add_menu_item(menu, new_idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 /* Want to update menus now even if mode not changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 force_menu_update = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 /* Sub-menu (not at end of path yet) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 gui_mch_add_menu(menu, new_idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 # if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 /* When adding a new submenu, may add a tearoff item */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 if ( addtearoff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 && *next_name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 && vim_strchr(p_go, GO_TEAROFF) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 && menu_is_menubar(name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 char_u *tearpath;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 * The pointers next_name & path_name refer to a string with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 * \'s and ^V's stripped out. But menu_path is a "raw"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 * string, so we must correct for special characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 tearpath = alloc((unsigned int)STRLEN(menu_path) + TEAR_LEN + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 if (tearpath != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 STRCPY(tearpath, menu_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 idx = (int)(next_name - path_name - 1);
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
664 for (s = tearpath; *s && s < tearpath + idx; mb_ptr_adv(s))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 if ((*s == '\\' || *s == Ctrl_V) && s[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 ++idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 ++s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 tearpath[idx] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 gui_add_tearoff(tearpath, pri_tab, pri_idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 vim_free(tearpath);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 #endif /* FEAT_GUI */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 menup = &menu->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 parent = menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 name = next_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 vim_free(dname);
928
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
685 dname = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 if (pri_tab[pri_idx + 1] != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 ++pri_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 vim_free(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 * Only add system menu items which have not been defined yet.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 * First check if this was an ":amenu".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 amenu = ((modes & (MENU_NORMAL_MODE | MENU_INSERT_MODE)) ==
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 (MENU_NORMAL_MODE | MENU_INSERT_MODE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 if (sys_menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 modes &= ~old_modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 if (menu != NULL && modes)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 menu->cb = gui_menu_cb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 p = (call_data == NULL) ? NULL : vim_strsave(call_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 /* loop over all modes, may add more than one */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 for (i = 0; i < MENU_MODES; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 if (modes & (1 << i))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 /* free any old menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 free_menu_string(menu, i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 /* For "amenu", may insert an extra character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 * Don't do this if adding a tearbar (addtearoff == FALSE).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 * Don't do this for "<Nop>". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 c = 0;
2149
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
719 d = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 if (amenu && call_data != NULL && *call_data != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 #ifdef FEAT_GUI_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 && addtearoff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 switch (1 << i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 case MENU_VISUAL_MODE:
791
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
729 case MENU_SELECT_MODE:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 case MENU_OP_PENDING_MODE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 case MENU_CMDLINE_MODE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 c = Ctrl_C;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 case MENU_INSERT_MODE:
2149
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
735 c = Ctrl_BSL;
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
736 d = Ctrl_O;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740
2149
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
741 if (c != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 {
2149
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
743 menu->strings[i] = alloc((unsigned)(STRLEN(call_data) + 5 ));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 if (menu->strings[i] != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 menu->strings[i][0] = c;
2149
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
747 if (d == 0)
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
748 STRCPY(menu->strings[i] + 1, call_data);
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
749 else
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
750 {
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
751 menu->strings[i][1] = d;
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
752 STRCPY(menu->strings[i] + 2, call_data);
4c8008ab94d8 updated for version 7.2.431
Bram Moolenaar <bram@zimbu.org>
parents: 1883
diff changeset
753 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 if (c == Ctrl_C)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 {
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 814
diff changeset
756 int len = (int)STRLEN(menu->strings[i]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 /* Append CTRL-\ CTRL-G to obey 'insertmode'. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 menu->strings[i][len] = Ctrl_BSL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 menu->strings[i][len + 1] = Ctrl_G;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 menu->strings[i][len + 2] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 menu->strings[i] = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 menu->noremap[i] = menuarg->noremap[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 menu->silent[i] = menuarg->silent[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 && (defined(FEAT_BEVAL) || defined(FEAT_GUI_GTK))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 /* Need to update the menu tip. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 if (modes & MENU_TIP_MODE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 gui_mch_menu_set_tip(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 erret:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 vim_free(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 vim_free(dname);
928
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
783
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
784 /* Delete any empty submenu we added before discovering the error. Repeat
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
785 * for higher levels. */
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
786 while (parent != NULL && parent->children == NULL)
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
787 {
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
788 if (parent->parent == NULL)
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
789 menup = &root_menu;
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
790 else
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
791 menup = &parent->parent->children;
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
792 for ( ; *menup != NULL && *menup != parent; menup = &((*menup)->next))
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
793 ;
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
794 if (*menup == NULL) /* safety check */
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
795 break;
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
796 parent = parent->parent;
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
797 free_menu(menup);
03c4ceec6bec updated for version 7.0-054
vimboss
parents: 860
diff changeset
798 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 * Set the (sub)menu with the given name to enabled or disabled.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 * Called recursively.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
807 menu_nable_recurse(
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
808 vimmenu_T *menu,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
809 char_u *name,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
810 int modes,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
811 int enable)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 if (menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 return OK; /* Got to bottom of hierarchy */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 /* Get name of this element in the menu hierarchy */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 p = menu_name_skip(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 /* Find the menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 while (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 if (*name == NUL || *name == '*' || menu_name_equal(name, menu))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 if (*p != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 if (menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 EMSG(_(e_notsubmenu));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 if (menu_nable_recurse(menu->children, p, modes, enable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 if (enable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 menu->enabled |= modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 menu->enabled &= ~modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 * When name is empty, we are doing all menu items for the given
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 * modes, so keep looping, otherwise we are just doing the named
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 * menu item (which has been found) so break here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 if (*name != NUL && *name != '*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 if (*name != NUL && *name != '*' && menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 {
436
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
855 EMSG2(_(e_nomenu), name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 /* Want to update menus now even if mode not changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 force_menu_update = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 * Remove the (sub)menu with the given name from the menu hierarchy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 * Called recursively.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
872 remove_menu(
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
873 vimmenu_T **menup,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
874 char_u *name,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
875 int modes,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
876 int silent) /* don't give error messages */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 vimmenu_T *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 if (*menup == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 return OK; /* Got to bottom of hierarchy */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 /* Get name of this element in the menu hierarchy */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 p = menu_name_skip(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 /* Find the menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 while ((menu = *menup) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 if (*name == NUL || menu_name_equal(name, menu))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 if (*p != NUL && menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 if (!silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 EMSG(_(e_notsubmenu));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 if ((menu->modes & modes) != 0x0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 #if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 * If we are removing all entries for this menu,MENU_ALL_MODES,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 * Then kill any tearoff before we start
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 if (*p == NUL && modes == MENU_ALL_MODES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 if (IsWindow(menu->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 DestroyWindow(menu->tearoff_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 if (remove_menu(&menu->children, p, modes, silent) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 else if (*name != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 if (!silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 EMSG(_(e_othermode));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 * When name is empty, we are removing all menu items for the given
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 * modes, so keep looping, otherwise we are just removing the named
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 * menu item (which has been found) so break here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 if (*name != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 /* Remove the menu item for the given mode[s]. If the menu item
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 * is no longer valid in ANY mode, delete it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 menu->modes &= ~modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 if (modes & MENU_TIP_MODE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 free_menu_string(menu, MENU_INDEX_TIP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 if ((menu->modes & MENU_ALL_MODES) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 free_menu(menup);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 menup = &menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 menup = &menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 if (*name != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 if (menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 if (!silent)
436
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
948 EMSG2(_(e_nomenu), name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 /* Recalculate modes for menu based on the new updated children */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 menu->modes &= ~modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 #if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 if ((s_tearoffs) && (menu->children != NULL)) /* there's a tear bar.. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 child = menu->children->next; /* don't count tearoff bar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 child = menu->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 for ( ; child != NULL; child = child->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 menu->modes |= child->modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 if (modes & MENU_TIP_MODE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 free_menu_string(menu, MENU_INDEX_TIP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 && (defined(FEAT_BEVAL) || defined(FEAT_GUI_GTK))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 /* Need to update the menu tip. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 gui_mch_menu_set_tip(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 if ((menu->modes & MENU_ALL_MODES) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 /* The menu item is no longer valid in ANY mode, so delete it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 #if defined(FEAT_GUI_W32) & defined(FEAT_TEAROFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 if (s_tearoffs && menu->children != NULL) /* there's a tear bar.. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 free_menu(&menu->children);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 *menup = menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 free_menu(menup);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 * Free the given menu structure and remove it from the linked list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 static void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
992 free_menu(vimmenu_T **menup)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 menu = *menup;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 /* Free machine specific menu structures (only when already created) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 /* Also may rebuild a tearoff'ed menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 gui_mch_destroy_menu(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 /* Don't change *menup until after calling gui_mch_destroy_menu(). The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 * MacOS code needs the original structure to properly delete the menu. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 *menup = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 vim_free(menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 vim_free(menu->dname);
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1011 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1012 vim_free(menu->en_name);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1013 vim_free(menu->en_dname);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1014 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 vim_free(menu->actext);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 vim_free(menu->iconfile);
162
7e6c3b196717 updated for version 7.0049
vimboss
parents: 41
diff changeset
1018 # ifdef FEAT_GUI_MOTIF
7e6c3b196717 updated for version 7.0049
vimboss
parents: 41
diff changeset
1019 vim_free(menu->xpm_fname);
7e6c3b196717 updated for version 7.0049
vimboss
parents: 41
diff changeset
1020 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 for (i = 0; i < MENU_MODES; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 free_menu_string(menu, i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 vim_free(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 /* Want to update menus now even if mode not changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 force_menu_update = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 * Free the menu->string with the given index.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 static void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1036 free_menu_string(vimmenu_T *menu, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 int count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 for (i = 0; i < MENU_MODES; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 if (menu->strings[i] == menu->strings[idx])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 count++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 if (count == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 vim_free(menu->strings[idx]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 menu->strings[idx] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 * Show the mapping associated with a menu item or hierarchy in a sub-menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1053 show_menus(char_u *path_name, int modes)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 vimmenu_T *parent = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 menu = root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 name = path_name = vim_strsave(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 if (path_name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 /* First, find the (sub)menu with the given name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 while (*name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 p = menu_name_skip(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 while (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 if (menu_name_equal(name, menu))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 /* Found menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 if (*p != NUL && menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 EMSG(_(e_notsubmenu));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 vim_free(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 else if ((menu->modes & modes) == 0x0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 EMSG(_(e_othermode));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 vim_free(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 if (menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 {
436
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1092 EMSG2(_(e_nomenu), name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 vim_free(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 name = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 parent = menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 menu = menu->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 }
1704
421a77b136c2 updated for version 7.2-002
vimboss
parents: 1624
diff changeset
1100 vim_free(path_name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 /* Now we have found the matching menu, and we list the mappings */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 /* Highlight title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 MSG_PUTS_TITLE(_("\n--- Menus ---"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 show_menus_recursive(parent, modes, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 * Recursively show the mappings associated with the menus under the given one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 static void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1114 show_menus_recursive(vimmenu_T *menu, int modes, int depth)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 int bit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 if (menu != NULL && (menu->modes & modes) == 0x0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 if (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 if (got_int) /* "q" hit for "--more--" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 for (i = 0; i < depth; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 MSG_PUTS(" ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 if (menu->priority)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 msg_outnum((long)menu->priority);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 MSG_PUTS(" ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 /* Same highlighting as for directories!? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 msg_outtrans_attr(menu->name, hl_attr(HLF_D));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 if (menu != NULL && menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 for (bit = 0; bit < MENU_MODES; bit++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 if ((menu->modes & modes & (1 << bit)) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 if (got_int) /* "q" hit for "--more--" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 for (i = 0; i < depth + 2; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 MSG_PUTS(" ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 msg_putchar(menu_mode_chars[bit]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 if (menu->noremap[bit] == REMAP_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 msg_putchar('*');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 else if (menu->noremap[bit] == REMAP_SCRIPT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 msg_putchar('&');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 if (menu->silent[bit])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 msg_putchar('s');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 if ((menu->modes & menu->enabled & (1 << bit)) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 msg_putchar('-');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 msg_putchar(' ');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 MSG_PUTS(" ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 if (*menu->strings[bit] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 msg_outtrans_special(menu->strings[bit], FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 if (menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 menu = root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 depth--;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 menu = menu->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 /* recursively show all children. Skip PopUp[nvoci]. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 for (; menu != NULL && !got_int; menu = menu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 if (!menu_is_hidden(menu->dname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 show_menus_recursive(menu, modes, depth + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 #ifdef FEAT_CMDL_COMPL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 * Used when expanding menu names.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 static vimmenu_T *expand_menu = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 static int expand_modes = 0x0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 static int expand_emenu; /* TRUE for ":emenu" command */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 * Work out what to complete when doing command line completion of menu names.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 char_u *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1200 set_context_in_menu_cmd(
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1201 expand_T *xp,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1202 char_u *cmd,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1203 char_u *arg,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1204 int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 char_u *after_dot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 char_u *path_name = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 int unmenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 int expand_menus;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 xp->xp_context = EXPAND_UNSUCCESSFUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 /* Check for priority numbers, enable and disable */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 for (p = arg; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 if (!VIM_ISDIGIT(*p) && *p != '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 if (!vim_iswhite(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 if (STRNCMP(arg, "enable", 6) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 && (arg[6] == NUL || vim_iswhite(arg[6])))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 p = arg + 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 else if (STRNCMP(arg, "disable", 7) == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 && (arg[7] == NUL || vim_iswhite(arg[7])))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 p = arg + 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 p = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 while (*p != NUL && vim_iswhite(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 arg = after_dot = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 for (; *p && !vim_iswhite(*p); ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 if ((*p == '\\' || *p == Ctrl_V) && p[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 else if (*p == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 after_dot = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 /* ":tearoff" and ":popup" only use menus, not entries */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 expand_menus = !((*cmd == 't' && cmd[1] == 'e') || *cmd == 'p');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 expand_emenu = (*cmd == 'e');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 if (expand_menus && vim_iswhite(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 return NULL; /* TODO: check for next command? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 if (*p == NUL) /* Complete the menu name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 * With :unmenu, you only want to match menus for the appropriate mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 * With :menu though you might want to add a menu with the same name as
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 * one in another mode, so match menus from other modes too.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 expand_modes = get_menu_cmd_modes(cmd, forceit, NULL, &unmenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 if (!unmenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 expand_modes = MENU_ALL_MODES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 menu = root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 if (after_dot != arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 path_name = alloc((unsigned)(after_dot - arg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 if (path_name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 return NULL;
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 162
diff changeset
1269 vim_strncpy(path_name, arg, after_dot - arg - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 name = path_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 while (name != NULL && *name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 p = menu_name_skip(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 while (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 if (menu_name_equal(name, menu))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 /* Found menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 if ((*p != NUL && menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 || ((menu->modes & expand_modes) == 0x0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 * Menu path continues, but we have reached a leaf.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 * Or menu exists only in another mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 vim_free(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 if (menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 /* No menu found with the name we were looking for */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 vim_free(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 name = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 menu = menu->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 }
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 838
diff changeset
1303 vim_free(path_name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 xp->xp_context = expand_menus ? EXPAND_MENUNAMES : EXPAND_MENUS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 xp->xp_pattern = after_dot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 expand_menu = menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 else /* We're in the mapping part */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 xp->xp_context = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 * Function given to ExpandGeneric() to obtain the list of (sub)menus (not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 * entries).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 char_u *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1319 get_menu_name(expand_T *xp UNUSED, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 static vimmenu_T *menu = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 char_u *str;
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1323 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1324 static int should_advance = FALSE;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1325 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 if (idx == 0) /* first call: start at first item */
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1328 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 menu = expand_menu;
2166
04c39cb3a10f Merge patch 7.2.434.
Bram Moolenaar <bram@vim.org>
parents: 2150
diff changeset
1330 #ifdef FEAT_MULTI_LANG
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1331 should_advance = FALSE;
2166
04c39cb3a10f Merge patch 7.2.434.
Bram Moolenaar <bram@vim.org>
parents: 2150
diff changeset
1332 #endif
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1333 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 /* Skip PopUp[nvoci]. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 while (menu != NULL && (menu_is_hidden(menu->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 || menu_is_separator(menu->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 || menu_is_tearoff(menu->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 || menu->children == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 if (menu == NULL) /* at end of linked list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 if (menu->modes & expand_modes)
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1346 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1347 if (should_advance)
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1348 str = menu->en_dname;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1349 else
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1350 {
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1351 #endif
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1352 str = menu->dname;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1353 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1354 if (menu->en_dname == NULL)
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1355 should_advance = TRUE;
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1356 }
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1357 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 str = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1361 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1362 if (should_advance)
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1363 #endif
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1364 /* Advance to next menu entry. */
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1365 menu = menu->next;
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1366
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1367 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1368 should_advance = !should_advance;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1369 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 return str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 * Function given to ExpandGeneric() to obtain the list of menus and menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 * entries.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 char_u *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1379 get_menu_names(expand_T *xp UNUSED, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 static vimmenu_T *menu = NULL;
2768
c5e47b752f07 updated for version 7.3.160
Bram Moolenaar <bram@vim.org>
parents: 2676
diff changeset
1382 #define TBUFFER_LEN 256
c5e47b752f07 updated for version 7.3.160
Bram Moolenaar <bram@vim.org>
parents: 2676
diff changeset
1383 static char_u tbuffer[TBUFFER_LEN]; /*hack*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 char_u *str;
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1385 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1386 static int should_advance = FALSE;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1387 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 if (idx == 0) /* first call: start at first item */
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1390 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 menu = expand_menu;
2166
04c39cb3a10f Merge patch 7.2.434.
Bram Moolenaar <bram@vim.org>
parents: 2150
diff changeset
1392 #ifdef FEAT_MULTI_LANG
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1393 should_advance = FALSE;
2166
04c39cb3a10f Merge patch 7.2.434.
Bram Moolenaar <bram@vim.org>
parents: 2150
diff changeset
1394 #endif
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1395 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 /* Skip Browse-style entries, popup menus and separators. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 while (menu != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 && ( menu_is_hidden(menu->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 || (expand_emenu && menu_is_separator(menu->dname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 || menu_is_tearoff(menu->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 #ifndef FEAT_BROWSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 || menu->dname[STRLEN(menu->dname) - 1] == '.'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 ))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 if (menu == NULL) /* at end of linked list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 if (menu->modes & expand_modes)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 if (menu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 {
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1415 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1416 if (should_advance)
2768
c5e47b752f07 updated for version 7.3.160
Bram Moolenaar <bram@vim.org>
parents: 2676
diff changeset
1417 vim_strncpy(tbuffer, menu->en_dname, TBUFFER_LEN - 2);
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1418 else
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1419 {
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1420 #endif
2768
c5e47b752f07 updated for version 7.3.160
Bram Moolenaar <bram@vim.org>
parents: 2676
diff changeset
1421 vim_strncpy(tbuffer, menu->dname, TBUFFER_LEN - 2);
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1422 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1423 if (menu->en_dname == NULL)
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1424 should_advance = TRUE;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1425 }
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1426 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 /* hack on menu separators: use a 'magic' char for the separator
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 * so that '.' in names gets escaped properly */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 STRCAT(tbuffer, "\001");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 str = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 else
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1433 #ifdef FEAT_MULTI_LANG
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1434 {
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1435 if (should_advance)
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1436 str = menu->en_dname;
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1437 else
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1438 {
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1439 #endif
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1440 str = menu->dname;
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1441 #ifdef FEAT_MULTI_LANG
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1442 if (menu->en_dname == NULL)
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1443 should_advance = TRUE;
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1444 }
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1445 }
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1446 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 str = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1451 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1452 if (should_advance)
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1453 #endif
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1454 /* Advance to next menu entry. */
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1455 menu = menu->next;
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1456
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1457 #ifdef FEAT_MULTI_LANG
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1458 should_advance = !should_advance;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1459 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 return str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 #endif /* FEAT_CMDL_COMPL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 * Skip over this element of the menu path and return the start of the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 * element. Any \ and ^Vs are removed from the current element.
436
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1468 * "name" may be modified.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 char_u *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1471 menu_name_skip(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
1475 for (p = name; *p && *p != '.'; mb_ptr_adv(p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 if (*p == '\\' || *p == Ctrl_V)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 {
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1050
diff changeset
1479 STRMOVE(p, p + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 if (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 *p++ = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 * Return TRUE when "name" matches with menu "menu". The name is compared in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 * two ways: raw menu name and menu name without '&'. ignore part after a TAB.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1494 menu_name_equal(char_u *name, vimmenu_T *menu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 {
2166
04c39cb3a10f Merge patch 7.2.434.
Bram Moolenaar <bram@vim.org>
parents: 2150
diff changeset
1496 #ifdef FEAT_MULTI_LANG
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1497 if (menu->en_name != NULL
2676
8464d084fa74 updated for version 7.3.095
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
1498 && (menu_namecmp(name, menu->en_name)
8464d084fa74 updated for version 7.3.095
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
1499 || menu_namecmp(name, menu->en_dname)))
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1500 return TRUE;
2166
04c39cb3a10f Merge patch 7.2.434.
Bram Moolenaar <bram@vim.org>
parents: 2150
diff changeset
1501 #endif
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
1502 return menu_namecmp(name, menu->name) || menu_namecmp(name, menu->dname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1506 menu_namecmp(char_u *name, char_u *mname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 for (i = 0; name[i] != NUL && name[i] != TAB; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 if (name[i] != mname[i])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 return ((name[i] == NUL || name[i] == TAB)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 && (mname[i] == NUL || mname[i] == TAB));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 * Return the modes specified by the given menu command (eg :menu! returns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 * MENU_CMDLINE_MODE | MENU_INSERT_MODE).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 * If "noremap" is not NULL, then the flag it points to is set according to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 * whether the command is a "nore" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 * If "unmenu" is not NULL, then the flag it points to is set according to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 * whether the command is an "unmenu" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1526 get_menu_cmd_modes(
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1527 char_u *cmd,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1528 int forceit, /* Was there a "!" after the command? */
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1529 int *noremap,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1530 int *unmenu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 int modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 switch (*cmd++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 case 'v': /* vmenu, vunmenu, vnoremenu */
791
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1537 modes = MENU_VISUAL_MODE | MENU_SELECT_MODE;
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1538 break;
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1539 case 'x': /* xmenu, xunmenu, xnoremenu */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 modes = MENU_VISUAL_MODE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 break;
791
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1542 case 's': /* smenu, sunmenu, snoremenu */
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1543 modes = MENU_SELECT_MODE;
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1544 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 case 'o': /* omenu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 modes = MENU_OP_PENDING_MODE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548 case 'i': /* imenu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 modes = MENU_INSERT_MODE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 case 't':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 modes = MENU_TIP_MODE; /* tmenu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 case 'c': /* cmenu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 modes = MENU_CMDLINE_MODE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 case 'a': /* amenu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 modes = MENU_INSERT_MODE | MENU_CMDLINE_MODE | MENU_NORMAL_MODE
791
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1559 | MENU_VISUAL_MODE | MENU_SELECT_MODE
856
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1560 | MENU_OP_PENDING_MODE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562 case 'n':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 if (*cmd != 'o') /* nmenu, not noremenu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 modes = MENU_NORMAL_MODE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 /* FALLTHROUGH */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 --cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571 if (forceit) /* menu!! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572 modes = MENU_INSERT_MODE | MENU_CMDLINE_MODE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 else /* menu */
791
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1574 modes = MENU_NORMAL_MODE | MENU_VISUAL_MODE | MENU_SELECT_MODE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575 | MENU_OP_PENDING_MODE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 if (noremap != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579 *noremap = (*cmd == 'n' ? REMAP_NONE : REMAP_YES);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580 if (unmenu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 *unmenu = (*cmd == 'u');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 return modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1583 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1585 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 * Modify a menu name starting with "PopUp" to include the mode character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 * Returns the name in allocated memory (NULL for failure).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589 static char_u *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1590 popup_mode_name(char_u *name, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1592 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1593 int len = (int)STRLEN(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595 p = vim_strnsave(name, len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1597 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 mch_memmove(p + 6, p + 5, (size_t)(len - 4));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 p[5] = menu_mode_chars[idx];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 #if defined(FEAT_GUI) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 * Return the index into the menu->strings or menu->noremap arrays for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607 * current state. Returns MENU_INDEX_INVALID if there is no mapping for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 * given menu in the current mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1609 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1610 int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1611 get_menu_index(vimmenu_T *menu, int state)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615 if ((state & INSERT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616 idx = MENU_INDEX_INSERT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617 else if (state & CMDLINE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 idx = MENU_INDEX_CMDLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 else if (VIsual_active)
791
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1620 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1621 if (VIsual_select)
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1622 idx = MENU_INDEX_SELECT;
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1623 else
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1624 idx = MENU_INDEX_VISUAL;
791
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1625 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626 else if (state == HITRETURN || state == ASKMORE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627 idx = MENU_INDEX_CMDLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 else if (finish_op)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 idx = MENU_INDEX_OP_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 else if ((state & NORMAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 idx = MENU_INDEX_NORMAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 idx = MENU_INDEX_INVALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 if (idx != MENU_INDEX_INVALID && menu->strings[idx] == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 idx = MENU_INDEX_INVALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 return idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 * Duplicate the menu item text and then process to see if a mnemonic key
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643 * and/or accelerator text has been identified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 * Returns a pointer to allocated memory, or NULL for failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 * If mnemonic != NULL, *mnemonic is set to the character after the first '&'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646 * If actext != NULL, *actext is set to the text after the first TAB.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 static char_u *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1649 menu_text(char_u *str, int *mnemonic, char_u **actext)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1654 /* Locate accelerator text, after the first TAB */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 p = vim_strchr(str, TAB);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1658 if (actext != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1659 *actext = vim_strsave(p + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1660 text = vim_strnsave(str, (int)(p - str));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1662 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1663 text = vim_strsave(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1664
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665 /* Find mnemonic characters "&a" and reduce "&&" to "&". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666 for (p = text; p != NULL; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 p = vim_strchr(p, '&');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 if (p[1] == NUL) /* trailing "&" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 if (mnemonic != NULL && p[1] != '&')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 #if !defined(__MVS__) || defined(MOTIF390_MNEMONIC_FIXED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 *mnemonic = p[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 * Well there is a bug in the Motif libraries on OS390 Unix.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 * The mnemonic keys needs to be converted to ASCII values
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 * first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 * This behavior has been seen in 2.8 and 2.9.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 char c = p[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 __etoa_l(&c, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686 *mnemonic = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688 #endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1050
diff changeset
1689 STRMOVE(p, p + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 p = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693 return text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 * Return TRUE if "name" can be a menu in the MenuBar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699 int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1700 menu_is_menubar(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 return (!menu_is_popup(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 && !menu_is_toolbar(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 && *name != MNU_HIDDEN_CHAR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 * Return TRUE if "name" is a popup menu name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1709 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710 int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1711 menu_is_popup(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1713 return (STRNCMP(name, "PopUp", 5) == 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 #if (defined(FEAT_GUI_MOTIF) && (XmVersion <= 1002)) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 * Return TRUE if "name" is part of a popup menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720 int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1721 menu_is_child_of_popup(vimmenu_T *menu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723 while (menu->parent != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1724 menu = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 return menu_is_popup(menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730 * Return TRUE if "name" is a toolbar menu name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732 int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1733 menu_is_toolbar(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1734 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1735 return (STRNCMP(name, "ToolBar", 7) == 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1738 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 * Return TRUE if the name is a menu separator identifier: Starts and ends
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740 * with '-'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1743 menu_is_separator(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 return (name[0] == '-' && name[STRLEN(name) - 1] == '-');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 * Return TRUE if the menu is hidden: Starts with ']'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1752 menu_is_hidden(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 return (name[0] == ']') || (menu_is_popup(name) && name[5] != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 #if defined(FEAT_CMDL_COMPL) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 || (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 * Return TRUE if the menu is the tearoff menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1763 menu_is_tearoff(char_u *name UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 return (STRCMP(name, TEAR_STRING) == 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 static int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1776 get_menu_mode(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 if (VIsual_active)
791
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1779 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1780 if (VIsual_select)
8cd729851562 updated for version 7.0g
vimboss
parents: 840
diff changeset
1781 return MENU_INDEX_SELECT;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 return MENU_INDEX_VISUAL;
791
98a88a884610 updated for version 7.0230
vimboss
parents: 700
diff changeset
1783 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 if (State & INSERT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 return MENU_INDEX_INSERT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 if ((State & CMDLINE) || State == ASKMORE || State == HITRETURN)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 return MENU_INDEX_CMDLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 if (finish_op)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 return MENU_INDEX_OP_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 if (State & NORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 return MENU_INDEX_NORMAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 if (State & LANGMAP) /* must be a "r" command, like Insert mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 return MENU_INDEX_INSERT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 return MENU_INDEX_INVALID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 /*
936
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1798 * Check that a pointer appears in the menu tree. Used to protect from using
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1799 * a menu that was deleted after it was selected but before the event was
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1800 * handled.
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1801 * Return OK or FAIL. Used recursively.
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1802 */
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1803 int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1804 check_menu_pointer(vimmenu_T *root, vimmenu_T *menu_to_check)
936
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1805 {
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1806 vimmenu_T *p;
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1807
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1808 for (p = root; p != NULL; p = p->next)
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1809 if (p == menu_to_check
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1810 || (p->children != NULL
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1811 && check_menu_pointer(p->children, menu_to_check) == OK))
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1812 return OK;
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1813 return FAIL;
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1814 }
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1815
77f8a648d2e6 updated for version 7.0-062
vimboss
parents: 928
diff changeset
1816 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 * After we have started the GUI, then we can create any menus that have been
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 * defined. This is done once here. add_menu_path() may have already been
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 * called to define these menus, and may be called again. This function calls
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 * itself recursively. Should be called at the top level with:
9536
b2aada04d84e commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents: 9264
diff changeset
1821 * gui_create_initial_menus(root_menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1824 gui_create_initial_menus(vimmenu_T *menu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 int idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 while (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830 /* Don't add a menu when only a tip was defined. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831 if (menu->modes & MENU_ALL_MODES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 if (menu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 gui_mch_add_menu(menu, idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 gui_create_initial_menus(menu->children);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839 gui_mch_add_menu_item(menu, idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842 ++idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847 * Used recursively by gui_update_menus (see below)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 static void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1850 gui_update_menus_recurse(vimmenu_T *menu, int mode)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 int grey;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 while (menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856 if ((menu->modes & menu->enabled & mode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 #if defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 || menu_is_tearoff(menu->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 grey = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 grey = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 #ifdef FEAT_GUI_ATHENA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 /* Hiding menus doesn't work for Athena, it can cause a crash. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 gui_mch_menu_grey(menu, grey);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 /* Never hide a toplevel menu, it may make the menubar resize or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 * disappear. Same problem for ToolBar items. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 if (vim_strchr(p_go, GO_GREY) != NULL || menu->parent == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 # ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872 || menu_is_toolbar(menu->parent->name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 gui_mch_menu_grey(menu, grey);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 gui_mch_menu_hidden(menu, grey);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879 gui_update_menus_recurse(menu->children, mode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1882 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1883
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 * Make sure only the valid menu items appear for this mode. If
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 * force_menu_update is not TRUE, then we only do this if the mode has changed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 * since last time. If "modes" is not 0, then we use these modes instead.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1890 gui_update_menus(int modes)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 static int prev_mode = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 int mode = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895 if (modes != 0x0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 mode = modes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 mode = get_menu_mode();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 if (mode == MENU_INDEX_INVALID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 mode = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 mode = (1 << mode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 if (force_menu_update || mode != prev_mode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 gui_update_menus_recurse(root_menu, mode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 gui_mch_draw_menubar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 prev_mode = mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 force_menu_update = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 #ifdef FEAT_GUI_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 /* This can leave a tearoff as active window - make sure we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 * have the focus <negri>*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 gui_mch_activate_window();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919
575
f1d46f948241 updated for version 7.0163
vimboss
parents: 533
diff changeset
1920 #if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) \
f1d46f948241 updated for version 7.0163
vimboss
parents: 533
diff changeset
1921 || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 * Check if a key is used as a mnemonic for a toplevel menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 * Case of the key is ignored.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926 int
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1927 gui_is_menu_shortcut(int key)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 if (key < 256)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 key = TOLOWER_LOC(key);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 for (menu = root_menu; menu != NULL; menu = menu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 if (menu->mnemonic == key
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1935 || (menu->mnemonic < 256 && TOLOWER_LOC(menu->mnemonic) == key))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1937 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 * Display the Special "PopUp" menu as a pop-up at the current mouse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 * position. The "PopUpn" menu is for Normal mode, "PopUpi" for Insert mode,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 * etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1947 gui_show_popupmenu(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 int mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 mode = get_menu_mode();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953 if (mode == MENU_INDEX_INVALID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 mode = menu_mode_chars[mode];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956
436
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1957 #ifdef FEAT_AUTOCMD
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1958 {
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1959 char_u ename[2];
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1960
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1961 ename[0] = mode;
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1962 ename[1] = NUL;
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1963 apply_autocmds(EVENT_MENUPOPUP, ename, NULL, FALSE, curbuf);
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1964 }
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1965 #endif
a1c5a6cb2675 updated for version 7.0112
vimboss
parents: 419
diff changeset
1966
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967 for (menu = root_menu; menu != NULL; menu = menu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 if (STRNCMP("PopUp", menu->name, 5) == 0 && menu->name[5] == mode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 /* Only show a popup when it is defined and has entries */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972 if (menu != NULL && menu->children != NULL)
9264
b0be59a89bde commit https://github.com/vim/vim/commit/2a67ed83a885e8e65e25498660dae4f34d532c7b
Christian Brabandt <cb@256bit.org>
parents: 8163
diff changeset
1973 {
b0be59a89bde commit https://github.com/vim/vim/commit/2a67ed83a885e8e65e25498660dae4f34d532c7b
Christian Brabandt <cb@256bit.org>
parents: 8163
diff changeset
1974 /* Update the menus now, in case the MenuPopup autocommand did
b0be59a89bde commit https://github.com/vim/vim/commit/2a67ed83a885e8e65e25498660dae4f34d532c7b
Christian Brabandt <cb@256bit.org>
parents: 8163
diff changeset
1975 * anything. */
b0be59a89bde commit https://github.com/vim/vim/commit/2a67ed83a885e8e65e25498660dae4f34d532c7b
Christian Brabandt <cb@256bit.org>
parents: 8163
diff changeset
1976 gui_update_menus(0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977 gui_mch_show_popupmenu(menu);
9264
b0be59a89bde commit https://github.com/vim/vim/commit/2a67ed83a885e8e65e25498660dae4f34d532c7b
Christian Brabandt <cb@256bit.org>
parents: 8163
diff changeset
1978 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 #endif /* FEAT_GUI */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1981
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 #if (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF)) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985 * Deal with tearoff items that are added like a menu item.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1986 * Currently only for Win32 GUI. Others may follow later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 gui_mch_toggle_tearoffs(int enable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 int pri_tab[MENUDEPTH + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995 if (enable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 for (i = 0; i < MENUDEPTH; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 pri_tab[i] = 500;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 pri_tab[MENUDEPTH] = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 gui_create_tearoffs_recurse(root_menu, (char_u *)"", pri_tab, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 gui_destroy_tearoffs_recurse(root_menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004 s_tearoffs = enable;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 * Recursively add tearoff items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 static void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2011 gui_create_tearoffs_recurse(
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2012 vimmenu_T *menu,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2013 const char_u *pname,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2014 int *pri_tab,
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2015 int pri_idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017 char_u *newpname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2018 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020 char_u *d;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022 if (pri_tab[pri_idx + 1] != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 ++pri_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 while (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026 if (menu->children != NULL && menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 /* Add the menu name to the menu path. Insert a backslash before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 * dots (it's used to separate menu names). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 len = (int)STRLEN(pname) + (int)STRLEN(menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031 for (s = menu->name; *s; ++s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 if (*s == '.' || *s == '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 ++len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034 newpname = alloc(len + TEAR_LEN + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 if (newpname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037 STRCPY(newpname, pname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038 d = newpname + STRLEN(newpname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039 for (s = menu->name; *s; ++s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 if (*s == '.' || *s == '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 *d++ = '\\';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 *d++ = *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 *d = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 /* check if tearoff already exists */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 if (STRCMP(menu->children->name, TEAR_STRING) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 gui_add_tearoff(newpname, pri_tab, pri_idx - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051 *d = NUL; /* remove TEAR_STRING */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 STRCAT(newpname, ".");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 gui_create_tearoffs_recurse(menu->children, newpname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 pri_tab, pri_idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 vim_free(newpname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 * Add tear-off menu item for a submenu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066 * "tearpath" is the menu path, and must have room to add TEAR_STRING.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 static void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2069 gui_add_tearoff(char_u *tearpath, int *pri_tab, int pri_idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 char_u *tbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 int t;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 vimmenu_T menuarg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 tbuf = alloc(5 + (unsigned int)STRLEN(tearpath));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 if (tbuf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 tbuf[0] = K_SPECIAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 tbuf[1] = K_SECOND(K_TEAROFF);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 tbuf[2] = K_THIRD(K_TEAROFF);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 STRCPY(tbuf + 3, tearpath);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 STRCAT(tbuf + 3, "\r");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084 STRCAT(tearpath, ".");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 STRCAT(tearpath, TEAR_STRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2087 /* Priority of tear-off is always 1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088 t = pri_tab[pri_idx + 1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089 pri_tab[pri_idx + 1] = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092 menuarg.iconfile = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2093 menuarg.iconidx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2094 menuarg.icon_builtin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 menuarg.noremap[0] = REMAP_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 menuarg.silent[0] = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2099 menuarg.modes = MENU_ALL_MODES;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2100 add_menu_path(tearpath, &menuarg, pri_tab, tbuf, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2102 menuarg.modes = MENU_TIP_MODE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2103 add_menu_path(tearpath, &menuarg, pri_tab,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2104 (char_u *)_("Tear off this menu"), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2106 pri_tab[pri_idx + 1] = t;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2107 vim_free(tbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112 * Recursively destroy tearoff items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 static void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2115 gui_destroy_tearoffs_recurse(vimmenu_T *menu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117 while (menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2118 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 if (menu->children)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 /* check if tearoff exists */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 if (STRCMP(menu->children->name, TEAR_STRING) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124 /* Disconnect the item and free the memory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 free_menu(&menu->children);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 if (menu->children != NULL) /* if not the last one */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128 gui_destroy_tearoffs_recurse(menu->children);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2129 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2130 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2134 #endif /* FEAT_GUI_W32 && FEAT_TEAROFF */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2137 * Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 * execute it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2141 ex_emenu(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 char_u *saved_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2148 char_u *mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150 saved_name = vim_strsave(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2151 if (saved_name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2152 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154 menu = root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 name = saved_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156 while (*name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2157 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 /* Find in the menu hierarchy */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2159 p = menu_name_skip(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2161 while (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2162 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2163 if (menu_name_equal(name, menu))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165 if (*p == NUL && menu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2167 EMSG(_("E333: Menu path must lead to a menu item"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2168 menu = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2169 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2170 else if (*p != NUL && menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2171 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2172 EMSG(_(e_notsubmenu));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2173 menu = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2174 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2175 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2179 if (menu == NULL || *p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2181 menu = menu->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2182 name = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 vim_free(saved_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185 if (menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187 EMSG2(_("E334: Menu not found: %s"), eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2188 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2189 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2190
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2191 /* Found the menu, so execute.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2192 * Use the Insert mode entry when returning to Insert mode. */
533
c8b6b7e1005d updated for version 7.0150
vimboss
parents: 436
diff changeset
2193 if (restart_edit
c8b6b7e1005d updated for version 7.0150
vimboss
parents: 436
diff changeset
2194 #ifdef FEAT_EVAL
c8b6b7e1005d updated for version 7.0150
vimboss
parents: 436
diff changeset
2195 && !current_SID
c8b6b7e1005d updated for version 7.0150
vimboss
parents: 436
diff changeset
2196 #endif
c8b6b7e1005d updated for version 7.0150
vimboss
parents: 436
diff changeset
2197 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2199 mode = (char_u *)"Insert";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2200 idx = MENU_INDEX_INSERT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2201 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202 else if (eap->addr_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204 pos_T tpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2206 mode = (char_u *)"Visual";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2207 idx = MENU_INDEX_VISUAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2209 /* GEDDES: This is not perfect - but it is a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210 * quick way of detecting whether we are doing this from a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2211 * selection - see if the range matches up with the visual
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2212 * select start and end. */
693
05dc93b9c61f updated for version 7.0208
vimboss
parents: 575
diff changeset
2213 if ((curbuf->b_visual.vi_start.lnum == eap->line1)
05dc93b9c61f updated for version 7.0208
vimboss
parents: 575
diff changeset
2214 && (curbuf->b_visual.vi_end.lnum) == eap->line2)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2215 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216 /* Set it up for visual mode - equivalent to gv. */
693
05dc93b9c61f updated for version 7.0208
vimboss
parents: 575
diff changeset
2217 VIsual_mode = curbuf->b_visual.vi_mode;
05dc93b9c61f updated for version 7.0208
vimboss
parents: 575
diff changeset
2218 tpos = curbuf->b_visual.vi_end;
05dc93b9c61f updated for version 7.0208
vimboss
parents: 575
diff changeset
2219 curwin->w_cursor = curbuf->b_visual.vi_start;
05dc93b9c61f updated for version 7.0208
vimboss
parents: 575
diff changeset
2220 curwin->w_curswant = curbuf->b_visual.vi_curswant;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2222 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224 /* Set it up for line-wise visual mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2225 VIsual_mode = 'V';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2226 curwin->w_cursor.lnum = eap->line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 curwin->w_cursor.col = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2228 tpos.lnum = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2229 tpos.col = MAXCOL;
700
c78d973dce9e updated for version 7.0211
vimboss
parents: 693
diff changeset
2230 #ifdef FEAT_VIRTUALEDIT
c78d973dce9e updated for version 7.0211
vimboss
parents: 693
diff changeset
2231 tpos.coladd = 0;
c78d973dce9e updated for version 7.0211
vimboss
parents: 693
diff changeset
2232 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2233 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2234
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2235 /* Activate visual mode */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2236 VIsual_active = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237 VIsual_reselect = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2238 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2239 VIsual = curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2240 curwin->w_cursor = tpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2242 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 /* Adjust the cursor to make sure it is in the correct pos
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2245 * for exclusive mode */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2246 if (*p_sel == 'e' && gchar_cursor() != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247 ++curwin->w_cursor.col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2251 mode = (char_u *)"Normal";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2252 idx = MENU_INDEX_NORMAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2255 if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 {
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2257 /* When executing a script or function execute the commands right now.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2258 * Otherwise put them in the typeahead buffer. */
1050
45fe7cf4a89e updated for version 7.0-176
vimboss
parents: 936
diff changeset
2259 #ifdef FEAT_EVAL
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2260 if (current_SID != 0)
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2261 exec_normal_cmd(menu->strings[idx], menu->noremap[idx],
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2262 menu->silent[idx]);
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2263 else
533
c8b6b7e1005d updated for version 7.0150
vimboss
parents: 436
diff changeset
2264 #endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
2265 ins_typebuf(menu->strings[idx], menu->noremap[idx], 0,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266 TRUE, menu->silent[idx]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269 EMSG2(_("E335: Menu not defined for %s mode"), mode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 #if defined(FEAT_GUI_MSWIN) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 || (defined(FEAT_GUI_GTK) && defined(FEAT_MENU)) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 || defined(FEAT_BEVAL_TIP) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276 * Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2277 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 vimmenu_T *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2279 gui_find_menu(char_u *path_name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 vimmenu_T *menu = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 char_u *saved_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2284 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286 menu = root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 saved_name = vim_strsave(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289 if (saved_name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2290 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2291
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 name = saved_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 while (*name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295 /* find the end of one dot-separated name and put a NUL at the dot */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296 p = menu_name_skip(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 while (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 {
2676
8464d084fa74 updated for version 7.3.095
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
2300 if (menu_name_equal(name, menu))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 if (menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2303 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 /* found a menu item instead of a sub-menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306 EMSG(_("E336: Menu path must lead to a sub-menu"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 EMSG(_(e_notsubmenu));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 menu = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312 if (*p == NUL) /* found a full match */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316 menu = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318 if (menu == NULL) /* didn't find it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2319 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321 /* Found a match, search the sub-menu. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2322 menu = menu->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 name = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2324 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2326 if (menu == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2327 EMSG(_("E337: Menu not found - check menu names"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2328 theend:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2329 vim_free(saved_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 return menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 #ifdef FEAT_MULTI_LANG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2335 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2336 * Translation of menu names. Just a simple lookup table.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2337 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341 char_u *from; /* English name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 char_u *from_noamp; /* same, without '&' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2343 char_u *to; /* translated name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2344 } menutrans_T;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2346 static garray_T menutrans_ga = {0, 0, 0, 0, NULL};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2347 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 * ":menutrans".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351 * This function is also defined without the +multi_lang feature, in which
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352 * case the commands are ignored.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2353 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2354 void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2355 ex_menutranslate(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2356 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357 #ifdef FEAT_MULTI_LANG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2358 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2359 menutrans_T *tp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2360 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361 char_u *from, *from_noamp, *to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 if (menutrans_ga.ga_itemsize == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2364 ga_init2(&menutrans_ga, (int)sizeof(menutrans_T), 5);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2365
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 * ":menutrans clear": clear all translations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 if (STRNCMP(arg, "clear", 5) == 0 && ends_excmd(*skipwhite(arg + 5)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 tp = (menutrans_T *)menutrans_ga.ga_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2372 for (i = 0; i < menutrans_ga.ga_len; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2373 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2374 vim_free(tp[i].from);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2375 vim_free(tp[i].from_noamp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2376 vim_free(tp[i].to);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2377 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2378 ga_clear(&menutrans_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 # ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2380 /* Delete all "menutrans_" global variables. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2381 del_menutrans_vars();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2382 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2383 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2384 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 /* ":menutrans from to": add translation */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2387 from = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2388 arg = menu_skip_part(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2389 to = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390 *arg = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 arg = menu_skip_part(to);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392 if (arg == to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393 EMSG(_(e_invarg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 if (ga_grow(&menutrans_ga, 1) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 tp = (menutrans_T *)menutrans_ga.ga_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 from = vim_strsave(from);
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2400 if (from != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 {
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2402 from_noamp = menu_text(from, NULL, NULL);
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2403 to = vim_strnsave(to, (int)(arg - to));
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2404 if (from_noamp != NULL && to != NULL)
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2405 {
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2406 menu_translate_tab_and_shift(from);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2407 menu_translate_tab_and_shift(to);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2408 menu_unescape_name(from);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2409 menu_unescape_name(to);
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2410 tp[menutrans_ga.ga_len].from = from;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2411 tp[menutrans_ga.ga_len].from_noamp = from_noamp;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2412 tp[menutrans_ga.ga_len].to = to;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2413 ++menutrans_ga.ga_len;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2414 }
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2415 else
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2416 {
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2417 vim_free(from);
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2418 vim_free(from_noamp);
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2419 vim_free(to);
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
2420 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2423 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2424 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2426 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2428 #if defined(FEAT_MULTI_LANG) || defined(FEAT_TOOLBAR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2429 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 * Find the character just after one part of a menu name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 static char_u *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2433 menu_skip_part(char_u *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435 while (*p != NUL && *p != '.' && !vim_iswhite(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437 if ((*p == '\\' || *p == Ctrl_V) && p[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2440 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2441 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2442 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2445 #ifdef FEAT_MULTI_LANG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2446 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 * Lookup part of a menu name in the translations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448 * Return a pointer to the translation or NULL if not found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 static char_u *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2451 menutrans_lookup(char_u *name, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 menutrans_T *tp = (menutrans_T *)menutrans_ga.ga_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 char_u *dname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457 for (i = 0; i < menutrans_ga.ga_len; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 if (STRNCMP(name, tp[i].from, len) == 0 && tp[i].from[len] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 return tp[i].to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461 /* Now try again while ignoring '&' characters. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 i = name[len];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463 name[len] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 dname = menu_text(name, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465 name[len] = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 if (dname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2467 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 for (i = 0; i < menutrans_ga.ga_len; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 if (STRCMP(dname, tp[i].from_noamp) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2471 vim_free(dname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2472 return tp[i].to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2473 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474 vim_free(dname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2476
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2480 /*
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2481 * Unescape the name in the translate dictionary table.
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2482 */
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2483 static void
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2484 menu_unescape_name(char_u *name)
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2485 {
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2486 char_u *p;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2487
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2488 for (p = name; *p && *p != '.'; mb_ptr_adv(p))
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2489 if (*p == '\\')
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2490 STRMOVE(p, p + 1);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2491 }
2251
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
2492 #endif /* FEAT_MULTI_LANG */
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2493
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2494 /*
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2495 * Isolate the menu name.
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2496 * Skip the menu name, and translate <Tab> into a real TAB.
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2497 */
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2498 static char_u *
7827
41789f16d6b2 commit https://github.com/vim/vim/commit/52ea13da0fe86df1abf34de52841e367035170c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2499 menu_translate_tab_and_shift(char_u *arg_start)
2150
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2500 {
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2501 char_u *arg = arg_start;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2502
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2503 while (*arg && !vim_iswhite(*arg))
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2504 {
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2505 if ((*arg == '\\' || *arg == Ctrl_V) && arg[1] != NUL)
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2506 arg++;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2507 else if (STRNICMP(arg, "<TAB>", 5) == 0)
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2508 {
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2509 *arg = TAB;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2510 STRMOVE(arg + 1, arg + 5);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2511 }
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2512 arg++;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2513 }
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2514 if (*arg != NUL)
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2515 *arg++ = NUL;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2516 arg = skipwhite(arg);
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2517
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2518 return arg;
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2519 }
4269a0673478 updated for version 7.2.432
Bram Moolenaar <bram@zimbu.org>
parents: 2149
diff changeset
2520
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 #endif /* FEAT_MENU */