neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

ex_getln_defs.h (2987B)


      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.
     11 typedef 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.
     20 typedef 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.
     26 typedef 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.
     33 typedef 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.
     42 typedef struct cmdline_info CmdlineInfo;
     43 struct 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  unsigned prompt_id;           ///< Prompt number, used to disable coloring on errors.
     61  Callback highlight_callback;  ///< Callback used for coloring user input.
     62  ColoredCmdline last_colors;   ///< Last cmdline colors
     63  int level;                    ///< current cmdline level
     64  CmdlineInfo *prev_ccline;     ///< pointer to saved cmdline state
     65  char special_char;            ///< last putcmdline char (used for redraws)
     66  bool special_shift;           ///< shift of last putcmdline char
     67  CmdRedraw redraw_state;       ///< needed redraw for external cmdline
     68  bool one_key;                 ///< return after one key press for button prompt
     69  bool *mouse_used;             ///< mouse clicked in prompt
     70 };