diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-21 06:33:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-21 06:33:24 +0800 |
commit | 0d0a336c5348c653376766d90a86f187167ae5c5 (patch) | |
tree | c2c47b69d3dca8361aff8038a12102ed2db81db2 /src/nvim/ex_getln.h | |
parent | ff5cfcdeab2446459ab59d44ce173ef811902c49 (diff) | |
download | rneovim-0d0a336c5348c653376766d90a86f187167ae5c5.tar.gz rneovim-0d0a336c5348c653376766d90a86f187167ae5c5.tar.bz2 rneovim-0d0a336c5348c653376766d90a86f187167ae5c5.zip |
vim-patch:8.1.1886: command line expansion code is spread out (#19861)
Problem: Command line expansion code is spread out.
Solution: Move the code to cmdexpand.c. (Yegappan Lakshmanan, closes vim/vim#4831)
https://github.com/vim/vim/commit/66b51420e0c8d49bcf6786b792c938d6099e3393
Diffstat (limited to 'src/nvim/ex_getln.h')
-rw-r--r-- | src/nvim/ex_getln.h | 107 |
1 files changed, 71 insertions, 36 deletions
diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h index 2f6929924d..5e3ad20a31 100644 --- a/src/nvim/ex_getln.h +++ b/src/nvim/ex_getln.h @@ -2,42 +2,77 @@ #define NVIM_EX_GETLN_H #include "nvim/eval/typval.h" -#include "nvim/ex_cmds.h" -#include "nvim/regexp_defs.h" - -// Values for nextwild() and ExpandOne(). See ExpandOne() for meaning. -#define WILD_FREE 1 -#define WILD_EXPAND_FREE 2 -#define WILD_EXPAND_KEEP 3 -#define WILD_NEXT 4 -#define WILD_PREV 5 -#define WILD_ALL 6 -#define WILD_LONGEST 7 -#define WILD_ALL_KEEP 8 -#define WILD_CANCEL 9 -#define WILD_APPLY 10 - -#define WILD_LIST_NOTFOUND 0x01 -#define WILD_HOME_REPLACE 0x02 -#define WILD_USE_NL 0x04 -#define WILD_NO_BEEP 0x08 -#define WILD_ADD_SLASH 0x10 -#define WILD_KEEP_ALL 0x20 -#define WILD_SILENT 0x40 -#define WILD_ESCAPE 0x80 -#define WILD_ICASE 0x100 -#define WILD_ALLLINKS 0x200 -#define WILD_IGNORE_COMPLETESLASH 0x400 -#define WILD_NOERROR 0x800 // sets EW_NOERROR -#define WILD_BUFLASTUSED 0x1000 -#define BUF_DIFF_FILTER 0x2000 - -// flags used by vim_strsave_fnameescape() -#define VSE_NONE 0 -#define VSE_SHELL 1 ///< escape for a shell command -#define VSE_BUFFER 2 ///< escape for a ":buffer" command - -typedef char *(*CompleteListItemGetter)(expand_T *, int); +#include "nvim/ex_cmds_defs.h" +#include "nvim/types.h" + +/// Command-line colors: one chunk +/// +/// Defines a region which has the same highlighting. +typedef struct { + int start; ///< Colored chunk start. + int end; ///< Colored chunk end (exclusive, > start). + int attr; ///< Highlight attr. +} CmdlineColorChunk; + +/// Command-line colors +/// +/// Holds data about all colors. +typedef kvec_t(CmdlineColorChunk) CmdlineColors; + +/// Command-line coloring +/// +/// Holds both what are the colors and what have been colored. Latter is used to +/// suppress unnecessary calls to coloring callbacks. +typedef struct { + unsigned prompt_id; ///< ID of the prompt which was colored last. + char *cmdbuff; ///< What exactly was colored last time or NULL. + CmdlineColors colors; ///< Last colors. +} ColoredCmdline; + +/// Keeps track how much state must be sent to external ui. +typedef enum { + kCmdRedrawNone, + kCmdRedrawPos, + kCmdRedrawAll, +} CmdRedraw; + +/// Variables shared between getcmdline(), redrawcmdline() and others. +/// These need to be saved when using CTRL-R |, that's why they are in a +/// structure. +typedef struct cmdline_info CmdlineInfo; +struct cmdline_info { + char_u *cmdbuff; ///< pointer to command line buffer + int cmdbufflen; ///< length of cmdbuff + int cmdlen; ///< number of chars in command line + int cmdpos; ///< current cursor position + int cmdspos; ///< cursor column on screen + int cmdfirstc; ///< ':', '/', '?', '=', '>' or NUL + int cmdindent; ///< number of spaces before cmdline + char_u *cmdprompt; ///< message in front of cmdline + int cmdattr; ///< attributes for prompt + int overstrike; ///< Typing mode on the command line. Shared by + ///< getcmdline() and put_on_cmdline(). + expand_T *xpc; ///< struct being used for expansion, xp_pattern + ///< may point into cmdbuff + int xp_context; ///< type of expansion + char_u *xp_arg; ///< user-defined expansion arg + int input_fn; ///< when true Invoked for input() function + unsigned prompt_id; ///< Prompt number, used to disable coloring on errors. + Callback highlight_callback; ///< Callback used for coloring user input. + ColoredCmdline last_colors; ///< Last cmdline colors + int level; ///< current cmdline level + CmdlineInfo *prev_ccline; ///< pointer to saved cmdline state + char special_char; ///< last putcmdline char (used for redraws) + bool special_shift; ///< shift of last putcmdline char + CmdRedraw redraw_state; ///< needed redraw for external cmdline +}; + +/// flags used by vim_strsave_fnameescape() +enum { + VSE_NONE = 0, + VSE_SHELL = 1, ///< escape for a shell command + VSE_BUFFER = 2, ///< escape for a ":buffer" command +}; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ex_getln.h.generated.h" |