aboutsummaryrefslogtreecommitdiff
path: root/src/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/menu.c')
-rw-r--r--src/menu.c147
1 files changed, 60 insertions, 87 deletions
diff --git a/src/menu.c b/src/menu.c
index 12e91b0ae6..95ac7bd5f5 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -13,6 +13,15 @@
*/
#include "vim.h"
+#include "menu.h"
+#include "charset.h"
+#include "eval.h"
+#include "ex_docmd.h"
+#include "getchar.h"
+#include "message.h"
+#include "misc1.h"
+#include "misc2.h"
+#include "term.h"
#define MENUDEPTH 10 /* maximum depth of menus */
@@ -53,8 +62,10 @@ static char_u e_nomenu[] = N_("E329: No menu \"%s\"");
/*
* Do the :menu command and relatives.
*/
-void ex_menu(eap)
-exarg_T *eap; /* Ex command arguments */
+void
+ex_menu (
+ exarg_T *eap /* Ex command arguments */
+)
{
char_u *menu_path;
int modes;
@@ -262,12 +273,14 @@ theend:
/*
* Add the menu with the given name to the menu hierarchy
*/
-static int add_menu_path(menu_path, menuarg, pri_tab, call_data)
-char_u *menu_path;
-vimmenu_T *menuarg; /* passes modes, iconfile, iconidx,
+static int
+add_menu_path (
+ char_u *menu_path,
+ vimmenu_T *menuarg, /* passes modes, iconfile, iconidx,
icon_builtin, silent[0], noremap[0] */
-int *pri_tab;
-char_u *call_data;
+ int *pri_tab,
+ char_u *call_data
+)
{
char_u *path_name;
int modes = menuarg->modes;
@@ -506,11 +519,7 @@ erret:
* Set the (sub)menu with the given name to enabled or disabled.
* Called recursively.
*/
-static int menu_nable_recurse(menu, name, modes, enable)
-vimmenu_T *menu;
-char_u *name;
-int modes;
-int enable;
+static int menu_nable_recurse(vimmenu_T *menu, char_u *name, int modes, int enable)
{
char_u *p;
@@ -559,11 +568,13 @@ int enable;
* Remove the (sub)menu with the given name from the menu hierarchy
* Called recursively.
*/
-static int remove_menu(menup, name, modes, silent)
-vimmenu_T **menup;
-char_u *name;
-int modes;
-int silent; /* don't give error messages */
+static int
+remove_menu (
+ vimmenu_T **menup,
+ char_u *name,
+ int modes,
+ int silent /* don't give error messages */
+)
{
vimmenu_T *menu;
vimmenu_T *child;
@@ -666,8 +677,7 @@ int silent; /* don't give error messages */
/*
* Free the given menu structure and remove it from the linked list.
*/
-static void free_menu(menup)
-vimmenu_T **menup;
+static void free_menu(vimmenu_T **menup)
{
int i;
vimmenu_T *menu;
@@ -692,9 +702,7 @@ vimmenu_T **menup;
/*
* Free the menu->string with the given index.
*/
-static void free_menu_string(menu, idx)
-vimmenu_T *menu;
-int idx;
+static void free_menu_string(vimmenu_T *menu, int idx)
{
int count = 0;
int i;
@@ -710,9 +718,7 @@ int idx;
/*
* Show the mapping associated with a menu item or hierarchy in a sub-menu.
*/
-static int show_menus(path_name, modes)
-char_u *path_name;
-int modes;
+static int show_menus(char_u *path_name, int modes)
{
char_u *p;
char_u *name;
@@ -765,10 +771,7 @@ int modes;
/*
* Recursively show the mappings associated with the menus under the given one
*/
-static void show_menus_recursive(menu, modes, depth)
-vimmenu_T *menu;
-int modes;
-int depth;
+static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
{
int i;
int bit;
@@ -844,11 +847,7 @@ static int expand_emenu; /* TRUE for ":emenu" command */
/*
* Work out what to complete when doing command line completion of menu names.
*/
-char_u * set_context_in_menu_cmd(xp, cmd, arg, forceit)
-expand_T *xp;
-char_u *cmd;
-char_u *arg;
-int forceit;
+char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forceit)
{
char_u *after_dot;
char_u *p;
@@ -952,9 +951,7 @@ int forceit;
* Function given to ExpandGeneric() to obtain the list of (sub)menus (not
* entries).
*/
-char_u * get_menu_name(xp, idx)
-expand_T *xp UNUSED;
-int idx;
+char_u *get_menu_name(expand_T *xp, int idx)
{
static vimmenu_T *menu = NULL;
char_u *str;
@@ -999,9 +996,7 @@ int idx;
* Function given to ExpandGeneric() to obtain the list of menus and menu
* entries.
*/
-char_u * get_menu_names(xp, idx)
-expand_T *xp UNUSED;
-int idx;
+char_u *get_menu_names(expand_T *xp, int idx)
{
static vimmenu_T *menu = NULL;
#define TBUFFER_LEN 256
@@ -1065,8 +1060,7 @@ int idx;
* element. Any \ and ^Vs are removed from the current element.
* "name" may be modified.
*/
-char_u * menu_name_skip(name)
-char_u *name;
+char_u *menu_name_skip(char_u *name)
{
char_u *p;
@@ -1086,9 +1080,7 @@ char_u *name;
* Return TRUE when "name" matches with menu "menu". The name is compared in
* two ways: raw menu name and menu name without '&'. ignore part after a TAB.
*/
-static int menu_name_equal(name, menu)
-char_u *name;
-vimmenu_T *menu;
+static int menu_name_equal(char_u *name, vimmenu_T *menu)
{
if (menu->en_name != NULL
&& (menu_namecmp(name, menu->en_name)
@@ -1097,9 +1089,7 @@ vimmenu_T *menu;
return menu_namecmp(name, menu->name) || menu_namecmp(name, menu->dname);
}
-static int menu_namecmp(name, mname)
-char_u *name;
-char_u *mname;
+static int menu_namecmp(char_u *name, char_u *mname)
{
int i;
@@ -1118,11 +1108,13 @@ char_u *mname;
* If "unmenu" is not NULL, then the flag it points to is set according to
* whether the command is an "unmenu" command.
*/
-static int get_menu_cmd_modes(cmd, forceit, noremap, unmenu)
-char_u *cmd;
-int forceit; /* Was there a "!" after the command? */
-int *noremap;
-int *unmenu;
+static int
+get_menu_cmd_modes (
+ char_u *cmd,
+ int forceit, /* Was there a "!" after the command? */
+ int *noremap,
+ int *unmenu
+)
{
int modes;
@@ -1179,9 +1171,7 @@ int *unmenu;
* Modify a menu name starting with "PopUp" to include the mode character.
* Returns the name in allocated memory (NULL for failure).
*/
-static char_u * popup_mode_name(name, idx)
-char_u *name;
-int idx;
+static char_u *popup_mode_name(char_u *name, int idx)
{
char_u *p;
int len = (int)STRLEN(name);
@@ -1202,10 +1192,7 @@ int idx;
* If mnemonic != NULL, *mnemonic is set to the character after the first '&'.
* If actext != NULL, *actext is set to the text after the first TAB.
*/
-static char_u * menu_text(str, mnemonic, actext)
-char_u *str;
-int *mnemonic;
-char_u **actext;
+static char_u *menu_text(char_u *str, int *mnemonic, char_u **actext)
{
char_u *p;
char_u *text;
@@ -1251,8 +1238,7 @@ char_u **actext;
/*
* Return TRUE if "name" can be a menu in the MenuBar.
*/
-int menu_is_menubar(name)
-char_u *name;
+int menu_is_menubar(char_u *name)
{
return !menu_is_popup(name)
&& !menu_is_toolbar(name)
@@ -1262,8 +1248,7 @@ char_u *name;
/*
* Return TRUE if "name" is a popup menu name.
*/
-int menu_is_popup(name)
-char_u *name;
+int menu_is_popup(char_u *name)
{
return STRNCMP(name, "PopUp", 5) == 0;
}
@@ -1272,8 +1257,7 @@ char_u *name;
/*
* Return TRUE if "name" is a toolbar menu name.
*/
-int menu_is_toolbar(name)
-char_u *name;
+int menu_is_toolbar(char_u *name)
{
return STRNCMP(name, "ToolBar", 7) == 0;
}
@@ -1282,8 +1266,7 @@ char_u *name;
* Return TRUE if the name is a menu separator identifier: Starts and ends
* with '-'
*/
-int menu_is_separator(name)
-char_u *name;
+int menu_is_separator(char_u *name)
{
return name[0] == '-' && name[STRLEN(name) - 1] == '-';
}
@@ -1291,8 +1274,7 @@ char_u *name;
/*
* Return TRUE if the menu is hidden: Starts with ']'
*/
-static int menu_is_hidden(name)
-char_u *name;
+static int menu_is_hidden(char_u *name)
{
return (name[0] == ']') || (menu_is_popup(name) && name[5] != NUL);
}
@@ -1302,8 +1284,7 @@ char_u *name;
/*
* Return TRUE if the menu is the tearoff menu.
*/
-static int menu_is_tearoff(name)
-char_u *name UNUSED;
+static int menu_is_tearoff(char_u *name)
{
return FALSE;
}
@@ -1315,8 +1296,7 @@ char_u *name UNUSED;
* Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy and
* execute it.
*/
-void ex_emenu(eap)
-exarg_T *eap;
+void ex_emenu(exarg_T *eap)
{
vimmenu_T *menu;
char_u *name;
@@ -1430,8 +1410,7 @@ exarg_T *eap;
/*
* Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy.
*/
-vimmenu_T * gui_find_menu(path_name)
-char_u *path_name;
+vimmenu_T *gui_find_menu(char_u *path_name)
{
vimmenu_T *menu = NULL;
char_u *name;
@@ -1499,8 +1478,7 @@ static garray_T menutrans_ga = {0, 0, 0, 0, NULL};
* This function is also defined without the +multi_lang feature, in which
* case the commands are ignored.
*/
-void ex_menutranslate(eap)
-exarg_T *eap UNUSED;
+void ex_menutranslate(exarg_T *eap)
{
char_u *arg = eap->arg;
menutrans_T *tp;
@@ -1562,8 +1540,7 @@ exarg_T *eap UNUSED;
/*
* Find the character just after one part of a menu name.
*/
-static char_u * menu_skip_part(p)
-char_u *p;
+static char_u *menu_skip_part(char_u *p)
{
while (*p != NUL && *p != '.' && !vim_iswhite(*p)) {
if ((*p == '\\' || *p == Ctrl_V) && p[1] != NUL)
@@ -1577,9 +1554,7 @@ char_u *p;
* Lookup part of a menu name in the translations.
* Return a pointer to the translation or NULL if not found.
*/
-static char_u * menutrans_lookup(name, len)
-char_u *name;
-int len;
+static char_u *menutrans_lookup(char_u *name, int len)
{
menutrans_T *tp = (menutrans_T *)menutrans_ga.ga_data;
int i;
@@ -1609,8 +1584,7 @@ int len;
/*
* Unescape the name in the translate dictionary table.
*/
-static void menu_unescape_name(name)
-char_u *name;
+static void menu_unescape_name(char_u *name)
{
char_u *p;
@@ -1623,8 +1597,7 @@ char_u *name;
* Isolate the menu name.
* Skip the menu name, and translate <Tab> into a real TAB.
*/
-static char_u * menu_translate_tab_and_shift(arg_start)
-char_u *arg_start;
+static char_u *menu_translate_tab_and_shift(char_u *arg_start)
{
char_u *arg = arg_start;