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