1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#pragma once
#include <stdint.h>
#include "klib/kvec.h"
#include "nvim/types_defs.h"
#define DECOR_ID_INVALID UINT32_MAX
typedef struct {
char *text;
int hl_id;
} VirtTextChunk;
typedef kvec_t(VirtTextChunk) VirtText;
#define VIRTTEXT_EMPTY ((VirtText)KV_INITIAL_VALUE)
typedef enum {
kVPosEndOfLine,
kVPosOverlay,
kVPosWinCol,
kVPosRightAlign,
kVPosInline,
} VirtTextPos;
typedef kvec_t(struct virt_line { VirtText line; bool left_col; }) VirtLines;
typedef uint16_t DecorPriority;
#define DECOR_PRIORITY_BASE 0x1000
typedef enum {
kHlModeUnknown,
kHlModeReplace,
kHlModeCombine,
kHlModeBlend,
} HlMode;
enum {
kSHIsSign = 1,
kSHHlEol = 2,
kSHUIWatched = 4,
kSHUIWatchedOverlay = 8,
kSHSpellOn = 16,
kSHSpellOff = 32,
kSHConceal = 64,
};
typedef struct {
uint16_t flags;
DecorPriority priority;
int hl_id;
schar_T conceal_char;
} DecorHighlightInline;
#define DECOR_HIGHLIGHT_INLINE_INIT { 0, DECOR_PRIORITY_BASE, 0, 0 }
typedef struct {
uint16_t flags;
DecorPriority priority;
int hl_id; // if sign: highlight of sign text
// TODO(bfredl): Later signs should use sc[2] as well.
union {
char *ptr; // sign
schar_T sc[2]; // conceal text (only sc[0] used)
} text;
// NOTE: if more functionality is added to a Highlight these should be overloaded
// or restructured
char *sign_name;
int sign_add_id;
int number_hl_id;
int line_hl_id;
int cursorline_hl_id;
uint32_t next;
} DecorSignHighlight;
#define DECOR_SIGN_HIGHLIGHT_INIT { 0, DECOR_PRIORITY_BASE, 0, { .ptr = NULL }, NULL, 0, 0, 0, 0, \
DECOR_ID_INVALID }
enum {
kVTIsLines = 1,
kVTHide = 2,
kVTLinesAbove = 4,
};
typedef struct DecorVirtText DecorVirtText;
struct DecorVirtText {
uint8_t flags;
uint8_t hl_mode;
DecorPriority priority;
int width; // width of virt_text
int col;
VirtTextPos pos;
// TODO(bfredl): reduce this to one datatype, later
union {
VirtText virt_text;
VirtLines virt_lines;
} data;
DecorVirtText *next;
};
#define DECOR_VIRT_TEXT_INIT { 0, kHlModeUnknown, DECOR_PRIORITY_BASE, 0, 0, kVPosEndOfLine, \
{ .virt_text = KV_INITIAL_VALUE }, NULL, }
#define DECOR_VIRT_LINES_INIT { kVTIsLines, kHlModeUnknown, DECOR_PRIORITY_BASE, 0, 0, \
kVPosEndOfLine, { .virt_lines = KV_INITIAL_VALUE }, NULL, }
typedef struct {
uint32_t sh_idx;
DecorVirtText *vt;
} DecorExt;
// Stored inline in marktree, with MT_FLAG_DECOR_EXT in MTKey.flags
typedef union {
DecorHighlightInline hl;
DecorExt ext;
} DecorInlineData;
// Not stored in the marktree, but used when passing around args
//
// Convention: an empty "no decoration" value should always be encoded
// with ext=false and an unset DecorHighlightInline (no flags, no hl_id)
typedef struct {
bool ext;
DecorInlineData data;
} DecorInline;
// initializes in a valid state for the DecorHighlightInline branch
#define DECOR_INLINE_INIT { .ext = false, .data.hl = DECOR_HIGHLIGHT_INLINE_INIT }
|