robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:9.2.0209: freeze during wildmenu completion (#38386)d36e7787c1

master
3.1 KiB72 linesraw
1#pragma once
2
3#include <stdbool.h>
4
5#include "klib/kvec.h"
6#include "nvim/cmdexpand_defs.h"
7
8/// Command-line colors: one chunk
9///
10/// Defines a region which has the same highlighting.
11typedef struct {
12  int start;  ///< Colored chunk start.
13  int end;    ///< Colored chunk end (exclusive, > start).
14  int hl_id;  ///< Highlight id.
15} CmdlineColorChunk;
16
17/// Command-line colors
18///
19/// Holds data about all colors.
20typedef kvec_t(CmdlineColorChunk) CmdlineColors;
21
22/// Command-line coloring
23///
24/// Holds both what are the colors and what have been colored. Latter is used to
25/// suppress unnecessary calls to coloring callbacks.
26typedef struct {
27  unsigned prompt_id;  ///< ID of the prompt which was colored last.
28  char *cmdbuff;  ///< What exactly was colored last time or NULL.
29  CmdlineColors colors;  ///< Last colors.
30} ColoredCmdline;
31
32/// Keeps track how much state must be sent to external ui.
33typedef enum {
34  kCmdRedrawNone,
35  kCmdRedrawPos,
36  kCmdRedrawAll,
37} CmdRedraw;
38
39/// Variables shared between getcmdline(), redrawcmdline() and others.
40/// These need to be saved when using CTRL-R |, that's why they are in a
41/// structure.
42typedef struct cmdline_info CmdlineInfo;
43struct cmdline_info {
44  char *cmdbuff;                ///< pointer to command line buffer
45  int cmdbufflen;               ///< length of cmdbuff
46  int cmdlen;                   ///< number of chars in command line
47  int cmdpos;                   ///< current cursor position
48  int cmdspos;                  ///< cursor column on screen
49  int cmdfirstc;                ///< ':', '/', '?', '=', '>' or NUL
50  int cmdindent;                ///< number of spaces before cmdline
51  char *cmdprompt;              ///< message in front of cmdline
52  int hl_id;                    ///< highlight id for prompt
53  int overstrike;               ///< Typing mode on the command line.  Shared by
54                                ///< getcmdline() and put_on_cmdline().
55  expand_T *xpc;                ///< struct being used for expansion, xp_pattern
56                                ///< may point into cmdbuff
57  int xp_context;               ///< type of expansion
58  char *xp_arg;                 ///< user-defined expansion arg
59  int input_fn;                 ///< when true Invoked for input() function
60  bool cmdbuff_replaced;        ///< when true cmdline was replaced externally
61                                ///< (e.g. by setcmdline())
62  unsigned prompt_id;           ///< Prompt number, used to disable coloring on errors.
63  Callback highlight_callback;  ///< Callback used for coloring user input.
64  ColoredCmdline last_colors;   ///< Last cmdline colors
65  int level;                    ///< current cmdline level
66  CmdlineInfo *prev_ccline;     ///< pointer to saved cmdline state
67  char special_char;            ///< last putcmdline char (used for redraws)
68  bool special_shift;           ///< shift of last putcmdline char
69  CmdRedraw redraw_state;       ///< needed redraw for external cmdline
70  bool one_key;                 ///< return after one key press for button prompt
71  bool *mouse_used;             ///< mouse clicked in prompt
72};