aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds_defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_cmds_defs.h')
-rw-r--r--src/nvim/ex_cmds_defs.h91
1 files changed, 65 insertions, 26 deletions
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index 3a9fd01dd9..4a40cc54b4 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -12,31 +12,29 @@
# include "ex_cmds_enum.generated.h"
#endif
-/*
- * When adding an Ex command:
- * 1. Add an entry to the table in src/nvim/ex_cmds.lua. Keep it sorted on the
- * shortest version of the command name that works. If it doesn't start with
- * a lower case letter, add it at the end.
- *
- * Each table entry is a table with the following keys:
- *
- * Key | Description
- * ------- | -------------------------------------------------------------
- * command | Name of the command. Required.
- * enum | Name of the enum entry. If not set defaults to CMD_{command}.
- * flags | A set of the flags from below list joined by bitwise or.
- * func | Name of the function containing the implementation.
- *
- * Referenced function should be either non-static one or defined in
- * ex_docmd.c and be coercible to ex_func_T type from below.
- *
- * All keys not described in the above table are reserved for future use.
- *
- * 2. Add a "case: CMD_xxx" in the big switch in ex_docmd.c.
- * 3. Add an entry in the index for Ex commands at ":help ex-cmd-index".
- * 4. Add documentation in ../doc/xxx.txt. Add a tag for both the short and
- * long name of the command.
- */
+// When adding an Ex command:
+// 1. Add an entry to the table in src/nvim/ex_cmds.lua. Keep it sorted on the
+// shortest version of the command name that works. If it doesn't start with
+// a lower case letter, add it at the end.
+//
+// Each table entry is a table with the following keys:
+//
+// Key | Description
+// ------- | -------------------------------------------------------------
+// command | Name of the command. Required.
+// enum | Name of the enum entry. If not set defaults to CMD_{command}.
+// flags | A set of the flags from below list joined by bitwise or.
+// func | Name of the function containing the implementation.
+//
+// Referenced function should be either non-static one or defined in
+// ex_docmd.c and be coercible to ex_func_T type from below.
+//
+// All keys not described in the above table are reserved for future use.
+//
+// 2. Add a "case: CMD_xxx" in the big switch in ex_docmd.c.
+// 3. Add an entry in the index for Ex commands at ":help ex-cmd-index".
+// 4. Add documentation in ../doc/xxx.txt. Add a tag for both the short and
+// long name of the command.
#define RANGE 0x001 /* allow a linespecs */
#define BANG 0x002 /* allow a ! after the command name */
@@ -98,6 +96,47 @@ typedef struct cmdname {
int cmd_addr_type; ///< Flag for address type
} CommandDefinition;
+// A list used for saving values of "emsg_silent". Used by ex_try() to save the
+// value of "emsg_silent" if it was non-zero. When this is done, the CSF_SILENT
+// flag below is set.
+typedef struct eslist_elem eslist_T;
+struct eslist_elem {
+ int saved_emsg_silent; // saved value of "emsg_silent"
+ eslist_T *next; // next element on the list
+};
+
+// For conditional commands a stack is kept of nested conditionals.
+// When cs_idx < 0, there is no conditional command.
+enum {
+ CSTACK_LEN = 50,
+};
+
+typedef struct {
+ int cs_flags[CSTACK_LEN]; // CSF_ flags
+ char cs_pending[CSTACK_LEN]; // CSTP_: what's pending in ":finally"
+ union {
+ void *csp_rv[CSTACK_LEN]; // return typeval for pending return
+ void *csp_ex[CSTACK_LEN]; // exception for pending throw
+ } cs_pend;
+ void *cs_forinfo[CSTACK_LEN]; // info used by ":for"
+ int cs_line[CSTACK_LEN]; // line nr of ":while"/":for" line
+ int cs_idx; // current entry, or -1 if none
+ int cs_looplevel; // nr of nested ":while"s and ":for"s
+ int cs_trylevel; // nr of nested ":try"s
+ eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent"
+ int cs_lflags; // loop flags: CSL_ flags
+} cstack_T;
+# define cs_rettv cs_pend.csp_rv
+# define cs_exception cs_pend.csp_ex
+
+// Flags for the cs_lflags item in cstack_T.
+enum {
+ CSL_HAD_LOOP = 1, // just found ":while" or ":for"
+ CSL_HAD_ENDLOOP = 2, // just found ":endwhile" or ":endfor"
+ CSL_HAD_CONT = 4, // just found ":continue"
+ CSL_HAD_FINA = 8, // just found ":finally"
+};
+
/// Arguments used for Ex commands.
struct exarg {
char_u *arg; ///< argument of the command
@@ -128,7 +167,7 @@ struct exarg {
char_u *errmsg; ///< returned error message
LineGetter getline; ///< Function used to get the next line
void *cookie; ///< argument for getline()
- struct condstack *cstack; ///< condition stack for ":if" etc.
+ cstack_T *cstack; ///< condition stack for ":if" etc.
};
#define FORCE_BIN 1 // ":edit ++bin file"