decoration.h
Go to the documentation of this file.
1 #ifndef NVIM_DECORATION_H
2 #define NVIM_DECORATION_H
3 
4 #include "nvim/buffer_defs.h"
5 #include "nvim/extmark_defs.h"
6 #include "nvim/pos.h"
7 
8 // actual Decoration data is in extmark_defs.h
9 
10 typedef uint16_t DecorPriority;
11 #define DECOR_PRIORITY_BASE 0x1000
12 
13 typedef enum {
18 } VirtTextPos;
19 
20 typedef enum {
25 } HlMode;
26 
27 typedef kvec_t(VirtTextChunk) VirtText;
28 #define VIRTTEXT_EMPTY ((VirtText)KV_INITIAL_VALUE)
29 
30 
31 typedef kvec_t(struct virt_line { VirtText line; bool left_col; }) VirtLines;
32 
33 
34 struct Decoration {
35  VirtText virt_text;
36  VirtLines virt_lines;
37 
38  int hl_id; // highlight group
41 
42  // TODO(bfredl): at some point turn this into FLAGS
44  bool hl_eol;
45  bool shared; // shared decoration, don't free
47  // TODO(bfredl): style, signs, etc
49  int col; // fixed col value, like win_col
50  int virt_text_width; // width of virt_text
51 };
52 #define DECORATION_INIT { KV_INITIAL_VALUE, KV_INITIAL_VALUE, 0, kVTEndOfLine, kHlModeUnknown, \
53  false, false, false, false, DECOR_PRIORITY_BASE, 0, 0 }
54 
55 typedef struct {
56  int start_row;
57  int start_col;
58  int end_row;
59  int end_col;
61  int attr_id; // cached lookup of decor.hl_id
63  int win_col;
64 } DecorRange;
65 
66 typedef struct {
67  MarkTreeIter itr[1];
70  int top_row;
71  int row;
72  int col_until;
73  int current;
74  int eol_col;
75 } DecorState;
76 
77 typedef struct {
79  bool active;
86  int hl_valid;
88 
89 EXTERN kvec_t(DecorProvider) decor_providers INIT(= KV_INITIAL_VALUE);
90 EXTERN DecorState decor_state INIT(= { 0 });
91 EXTERN bool provider_active INIT(= false);
92 
93 #define DECORATION_PROVIDER_INIT(ns_id) (DecorProvider) \
94  { ns_id, false, LUA_NOREF, LUA_NOREF, \
95  LUA_NOREF, LUA_NOREF, LUA_NOREF, \
96  LUA_NOREF, -1 }
97 
98 #ifdef INCLUDE_GENERATED_DECLARATIONS
99 # include "decoration.h.generated.h"
100 #endif
101 
102 #endif // NVIM_DECORATION_H
VirtTextPos
VirtTextPos
Definition: decoration.h:13
DecorProvider::redraw_win
LuaRef redraw_win
Definition: decoration.h:82
Decoration::virt_lines_above
bool virt_lines_above
Definition: decoration.h:46
DecorState
Definition: decoration.h:66
kVTEndOfLine
@ kVTEndOfLine
Definition: decoration.h:14
DecorPriority
uint16_t DecorPriority
Definition: decoration.h:10
NS
handle_T NS
Definition: types.h:25
DecorProvider::redraw_line
LuaRef redraw_line
Definition: decoration.h:83
Decoration::virt_text_width
int virt_text_width
Definition: decoration.h:50
Decoration::virt_text_pos
VirtTextPos virt_text_pos
Definition: decoration.h:39
Decoration::col
int col
Definition: decoration.h:49
kHlModeBlend
@ kHlModeBlend
Definition: decoration.h:24
DecorState::current
int current
Definition: decoration.h:73
KV_INITIAL_VALUE
#define KV_INITIAL_VALUE
Definition: kvec.h:51
Decoration::shared
bool shared
Definition: decoration.h:45
DecorState::top_row
int top_row
Definition: decoration.h:70
DecorState::row
int row
Definition: decoration.h:71
DecorRange::end_row
int end_row
Definition: decoration.h:58
DecorRange::decor
Decoration decor
Definition: decoration.h:60
Decoration::hl_eol
bool hl_eol
Definition: decoration.h:44
DecorRange::win_col
int win_col
Definition: decoration.h:63
INIT
EXTERN DecorState decor_state INIT(={ 0 })
LuaRef
int LuaRef
Definition: types.h:23
DecorProvider::hl_def
LuaRef hl_def
Definition: decoration.h:85
DecorRange::attr_id
int attr_id
Definition: decoration.h:61
Decoration::virt_lines
VirtLines virt_lines
Definition: decoration.h:36
DecorProvider::redraw_end
LuaRef redraw_end
Definition: decoration.h:84
kVTRightAlign
@ kVTRightAlign
Definition: decoration.h:17
DecorRange::start_row
int start_row
Definition: decoration.h:56
HlMode
HlMode
Definition: decoration.h:20
Decoration::virt_text_hide
bool virt_text_hide
Definition: decoration.h:43
DecorProvider::ns_id
NS ns_id
Definition: decoration.h:78
DecorRange
Definition: decoration.h:55
DecorProvider
Definition: decoration.h:77
MarkTreeIter
Definition: marktree.h:31
VirtTextChunk
Definition: extmark_defs.h:9
Decoration::hl_mode
HlMode hl_mode
Definition: decoration.h:40
active
bool active
Definition: edit.c:219
DecorState::buf
buf_T * buf
Definition: decoration.h:69
kHlModeUnknown
@ kHlModeUnknown
Definition: decoration.h:21
Decoration::priority
DecorPriority priority
Definition: decoration.h:48
DecorProvider::hl_valid
int hl_valid
Definition: decoration.h:86
extmark_defs.h
kvec_t
typedef kvec_t(VirtTextChunk) VirtText
EXTERN
#define EXTERN
Definition: macros.h:9
line
void const char * line
Definition: eval.c:7344
DecorRange::virt_text_owned
bool virt_text_owned
Definition: decoration.h:62
DecorState::eol_col
int eol_col
Definition: decoration.h:74
DecorRange::start_col
int start_col
Definition: decoration.h:57
file_buffer
Definition: buffer_defs.h:516
Decoration::virt_text
VirtText virt_text
Definition: decoration.h:35
buffer_defs.h
kVTWinCol
@ kVTWinCol
Definition: decoration.h:16
kVTOverlay
@ kVTOverlay
Definition: decoration.h:15
DecorRange::end_col
int end_col
Definition: decoration.h:59
Decoration::hl_id
int hl_id
Definition: decoration.h:38
DecorProvider::redraw_buf
LuaRef redraw_buf
Definition: decoration.h:81
kHlModeReplace
@ kHlModeReplace
Definition: decoration.h:22
DecorProvider::redraw_start
LuaRef redraw_start
Definition: decoration.h:80
kHlModeCombine
@ kHlModeCombine
Definition: decoration.h:23
DecorProvider::active
bool active
Definition: decoration.h:79
DecorState::col_until
int col_until
Definition: decoration.h:72
Decoration
Definition: decoration.h:34
pos.h