robin/laufey

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

glepnirfix(api): expose fg_indexed/bg_indexed in nvim_get_hl #3921001861c2f95

master
6.0 KiB184 linesraw
1#pragma once
2
3#include <stdbool.h>
4#include <stdint.h>
5
6#include "nvim/api/private/defs.h"
7
8typedef int32_t RgbValue;
9
10/// Highlighting attribute bits.
11///
12/// sign bit should not be used here, as it identifies invalid highlight
13typedef enum {
14  HL_INVERSE         = 0x01,
15  HL_BOLD            = 0x02,
16  HL_ITALIC          = 0x04,
17  // The next three bits are all underline styles
18  HL_UNDERLINE_MASK  = 0x38,
19  HL_UNDERLINE       = 0x08,
20  HL_UNDERCURL       = 0x10,
21  HL_UNDERDOUBLE     = 0x18,
22  HL_UNDERDOTTED     = 0x20,
23  HL_UNDERDASHED     = 0x28,
24  // 0x30 and 0x38 spare for underline styles
25  HL_STANDOUT      = 0x0040,
26  HL_STRIKETHROUGH = 0x0080,
27  HL_ALTFONT       = 0x0100,
28  HL_DIM           = 0x0200,
29  HL_BLINK         = 0x8000,
30  // SGR attribute, unrelated to HL_CONCEAL syntax flag.
31  HL_CONCEALED     = 0x10000,
32  HL_OVERLINE      = 0x20000,
33  HL_NOCOMBINE     = 0x0400,
34  HL_BG_INDEXED    = 0x0800,
35  HL_FG_INDEXED    = 0x1000,
36  HL_DEFAULT       = 0x2000,
37  HL_GLOBAL        = 0x4000,
38} HlAttrFlags;
39
40/// Stores a complete highlighting entry, including colors and attributes
41/// for both TUI and GUI.
42typedef struct {
43  int32_t rgb_ae_attr, cterm_ae_attr;  ///< HlAttrFlags
44  RgbValue rgb_fg_color, rgb_bg_color, rgb_sp_color;
45  int16_t cterm_fg_color, cterm_bg_color;
46  int32_t hl_blend;
47  int32_t url;
48  int32_t font;
49} HlAttrs;
50
51#define HLATTRS_INIT (HlAttrs) { \
52  .rgb_ae_attr = 0, \
53  .cterm_ae_attr = 0, \
54  .rgb_fg_color = -1, \
55  .rgb_bg_color = -1, \
56  .rgb_sp_color = -1, \
57  .cterm_fg_color = 0, \
58  .cterm_bg_color = 0, \
59  .hl_blend = -1, \
60  .url = -1, \
61  .font = -1, \
62}
63
64/// Values for index in highlight_attr[].
65/// When making changes, also update hlf_names in highlight.h!
66typedef enum {
67  HLF_NONE = 0,   ///< no UI highlight active
68  HLF_8,          ///< Meta & special keys listed with ":map", text that is
69                  ///< displayed different from what it is
70  HLF_EOB,        ///< after the last line in the buffer
71  HLF_TERM,       ///< terminal cursor focused
72  HLF_AT,         ///< @ characters at end of screen, characters that don't really exist in the text
73  HLF_D,          ///< directories in CTRL-D listing
74  HLF_E,          ///< error messages
75  HLF_I,          ///< incremental search
76  HLF_L,          ///< last search string
77  HLF_LC,         ///< current search match
78  HLF_M,          ///< "--More--" message
79  HLF_CM,         ///< Mode (e.g., "-- INSERT --")
80  HLF_N,          ///< line number for ":number" and ":#" commands
81  HLF_LNA,        ///< LineNrAbove
82  HLF_LNB,        ///< LineNrBelow
83  HLF_CLN,        ///< current line number when 'cursorline' is set
84  HLF_CLS,        ///< current line sign column
85  HLF_CLF,        ///< current line fold
86  HLF_R,          ///< return to continue message and yes/no questions
87  HLF_S,          ///< status lines
88  HLF_SNC,        ///< status lines of not-current windows
89  HLF_C,          ///< window split separators
90  HLF_VSP,        ///< VertSplit
91  HLF_T,          ///< Titles for output from ":set all", ":autocmd" etc.
92  HLF_V,          ///< Visual mode
93  HLF_VNC,        ///< Visual mode, autoselecting and not clipboard owner
94  HLF_W,          ///< warning messages
95  HLF_WM,         ///< Wildmenu highlight
96  HLF_FL,         ///< Folded line
97  HLF_FC,         ///< Fold column
98  HLF_ADD,        ///< Added diff line
99  HLF_CHD,        ///< Changed diff line
100  HLF_DED,        ///< Deleted diff line
101  HLF_TXD,        ///< Text Changed in diff line
102  HLF_TXA,        ///< Text Added in changed diff line
103  HLF_SC,         ///< Sign column
104  HLF_CONCEAL,    ///< Concealed text
105  HLF_SPB,        ///< SpellBad
106  HLF_SPC,        ///< SpellCap
107  HLF_SPR,        ///< SpellRare
108  HLF_SPL,        ///< SpellLocal
109  HLF_PNI,        ///< popup menu normal item
110  HLF_PSI,        ///< popup menu selected item
111  HLF_PMNI,       ///< popup menu matched text in normal item
112  HLF_PMSI,       ///< popup menu matched text in selected item
113  HLF_PNK,        ///< popup menu normal item "kind"
114  HLF_PSK,        ///< popup menu selected item "kind"
115  HLF_PNX,        ///< popup menu normal item "menu" (extra text)
116  HLF_PSX,        ///< popup menu selected item "menu" (extra text)
117  HLF_PSB,        ///< popup menu scrollbar
118  HLF_PST,        ///< popup menu scrollbar thumb
119  HLF_PBR,        ///< popup menu border
120  HLF_TP,         ///< tabpage line
121  HLF_TPS,        ///< tabpage line selected
122  HLF_TPF,        ///< tabpage line filler
123  HLF_CUC,        ///< 'cursorcolumn'
124  HLF_CUL,        ///< 'cursorline'
125  HLF_MC,         ///< 'colorcolumn'
126  HLF_QFL,        ///< selected quickfix line
127  HLF_0,          ///< Whitespace
128  HLF_INACTIVE,   ///< NormalNC: Normal text in non-current windows
129  HLF_MSGSEP,     ///< message separator line
130  HLF_NFLOAT,     ///< Floating window
131  HLF_MSG,        ///< Message area
132  HLF_BORDER,     ///< Floating window border
133  HLF_WBR,        ///< Window bars
134  HLF_WBRNC,      ///< Window bars of not-current windows
135  HLF_CU,         ///< Cursor
136  HLF_BTITLE,     ///< Float Border Title
137  HLF_BFOOTER,    ///< Float Border Footer
138  HLF_TS,         ///< status line for terminal window
139  HLF_TSNC,       ///< status line for non-current terminal window
140  HLF_SE,         ///< stderr messages (from shell)
141  HLF_SO,         ///< stdout messages (from shell)
142  HLF_OK,         ///< OK message
143  HLF_PRE,        ///< "preinsert" in 'completeopt'
144  HLF_COUNT,      ///< MUST be the last one
145} hlf_T;
146
147typedef enum {
148  kHlUnknown,
149  kHlUI,
150  kHlSyntax,
151  kHlTerminal,
152  kHlCombine,
153  kHlBlend,
154  kHlBlendThrough,
155  kHlInvalid,
156} HlKind;
157
158typedef struct {
159  HlAttrs attr;
160  HlKind kind;
161  int id1;
162  int id2;
163  int winid;
164} HlEntry;
165
166typedef struct {
167  int ns_id;
168  int syn_id;
169} ColorKey;
170#define ColorKey(n, s) (ColorKey) { .ns_id = (int)(n), .syn_id = (s) }
171
172#define HlAttrKey(a, b) ((uint64_t)(uint32_t)(a) << 32 | (uint32_t)(b))
173
174typedef struct {
175  int attr_id;
176  int link_id;
177  int version;
178  bool is_default;
179  bool link_global;
180} ColorItem;
181#define COLOR_ITEM_INITIALIZER { .attr_id = -1, .link_id = -1, .version = -1, \
182                                 .is_default = false, .link_global = false }
183
184enum { HLATTRS_DICT_SIZE = 24, };