robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
d36e7787c1
master
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 { 12int start ;///< Colored chunk start. 13int end ;///< Colored chunk end (exclusive, > start). 14int 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 { 27unsigned prompt_id ;///< ID of the prompt which was colored last. 28char * cmdbuff ;///< What exactly was colored last time or NULL. 29CmdlineColors colors ;///< Last colors. 30}ColoredCmdline ; 31 32/// Keeps track how much state must be sent to external ui. 33typedef enum { 34kCmdRedrawNone , 35kCmdRedrawPos , 36kCmdRedrawAll , 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 { 44char * cmdbuff ;///< pointer to command line buffer 45int cmdbufflen ;///< length of cmdbuff 46int cmdlen ;///< number of chars in command line 47int cmdpos ;///< current cursor position 48int cmdspos ;///< cursor column on screen 49int cmdfirstc ;///< ':', '/', '?', '=', '>' or NUL 50int cmdindent ;///< number of spaces before cmdline 51char * cmdprompt ;///< message in front of cmdline 52int hl_id ;///< highlight id for prompt 53int overstrike ;///< Typing mode on the command line. Shared by 54///< getcmdline() and put_on_cmdline(). 55expand_T * xpc ;///< struct being used for expansion, xp_pattern 56///< may point into cmdbuff 57int xp_context ;///< type of expansion 58char * xp_arg ;///< user-defined expansion arg 59int input_fn ;///< when true Invoked for input() function 60bool cmdbuff_replaced ;///< when true cmdline was replaced externally 61///< (e.g. by setcmdline()) 62unsigned prompt_id ;///< Prompt number, used to disable coloring on errors. 63Callback highlight_callback ;///< Callback used for coloring user input. 64ColoredCmdline last_colors ;///< Last cmdline colors 65int level ;///< current cmdline level 66CmdlineInfo * prev_ccline ;///< pointer to saved cmdline state 67char special_char ;///< last putcmdline char (used for redraws) 68bool special_shift ;///< shift of last putcmdline char 69CmdRedraw redraw_state ;///< needed redraw for external cmdline 70bool one_key ;///< return after one key press for button prompt 71bool * mouse_used ;///< mouse clicked in prompt 72};