neovim

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

highlight_defs.h (6161B)


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