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