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 EXTERN const char *const virt_text_pos_str[] INIT(= { "eol", "overlay", "win_col", "right_align" });
21 
22 typedef enum {
27 } HlMode;
28 
29 EXTERN const char *const hl_mode_str[] INIT(= { "", "replace", "combine", "blend" });
30 
31 typedef kvec_t(VirtTextChunk) VirtText;
32 #define VIRTTEXT_EMPTY ((VirtText)KV_INITIAL_VALUE)
33 
34 
35 typedef kvec_t(struct virt_line { VirtText line; bool left_col; }) VirtLines;
36 
37 
38 struct Decoration {
39  VirtText virt_text;
40  VirtLines virt_lines;
41 
42  int hl_id; // highlight group
45 
46  // TODO(bfredl): at some point turn this into FLAGS
48  bool hl_eol;
50  bool conceal;
51  // TODO(bfredl): style, etc
53  int col; // fixed col value, like win_col
54  int virt_text_width; // width of virt_text
60  // TODO(bfredl): in principle this should be a schar_T, but we
61  // probably want some kind of glyph cache for that..
63  bool ui_watched; // watched for win_extmark
64 };
65 #define DECORATION_INIT { KV_INITIAL_VALUE, KV_INITIAL_VALUE, 0, kVTEndOfLine, \
66  kHlModeUnknown, false, false, false, false, DECOR_PRIORITY_BASE, \
67  0, 0, NULL, 0, 0, 0, 0, 0, false }
68 
69 typedef struct {
70  int start_row;
71  int start_col;
72  int end_row;
73  int end_col;
75  int attr_id; // cached lookup of decor.hl_id
77  int win_col;
78  uint64_t ns_id;
79  uint64_t mark_id;
80 } DecorRange;
81 
82 typedef struct {
83  MarkTreeIter itr[1];
86  int top_row;
87  int row;
88  int col_until;
89  int current;
90  int eol_col;
91 
92  bool conceal;
95 } DecorState;
96 
97 EXTERN DecorState decor_state INIT(= { 0 });
98 
99 static inline bool decor_has_sign(Decoration *decor)
100 {
101  return decor->sign_text
102  || decor->sign_hl_id
103  || decor->number_hl_id
104  || decor->line_hl_id
105  || decor->cursorline_hl_id;
106 }
107 
108 #ifdef INCLUDE_GENERATED_DECLARATIONS
109 # include "decoration.h.generated.h"
110 #endif
111 
112 #endif // NVIM_DECORATION_H
VirtTextPos
VirtTextPos
Definition: decoration.h:13
Decoration::virt_lines_above
bool virt_lines_above
Definition: decoration.h:49
Decoration::line_hl_id
int line_hl_id
Definition: decoration.h:58
INIT
const EXTERN char *const virt_text_pos_str[] INIT(={ "eol", "overlay", "win_col", "right_align" })
DecorState
Definition: decoration.h:82
kVTEndOfLine
@ kVTEndOfLine
Definition: decoration.h:14
Decoration::number_hl_id
int number_hl_id
Definition: decoration.h:57
DecorPriority
uint16_t DecorPriority
Definition: decoration.h:10
Decoration::virt_text_width
int virt_text_width
Definition: decoration.h:54
Decoration::virt_text_pos
VirtTextPos virt_text_pos
Definition: decoration.h:43
Decoration::col
int col
Definition: decoration.h:53
kHlModeBlend
@ kHlModeBlend
Definition: decoration.h:26
DecorState::current
int current
Definition: decoration.h:89
DecorState::top_row
int top_row
Definition: decoration.h:86
DecorState::row
int row
Definition: decoration.h:87
DecorRange::end_row
int end_row
Definition: decoration.h:72
DecorRange::decor
Decoration decor
Definition: decoration.h:74
Decoration::ui_watched
bool ui_watched
Definition: decoration.h:63
Decoration::hl_eol
bool hl_eol
Definition: decoration.h:48
Decoration::sign_text
char_u * sign_text
Definition: decoration.h:55
DecorRange::win_col
int win_col
Definition: decoration.h:77
Decoration::cursorline_hl_id
int cursorline_hl_id
Definition: decoration.h:59
Decoration::conceal
bool conceal
Definition: decoration.h:50
DecorRange::attr_id
int attr_id
Definition: decoration.h:75
Decoration::virt_lines
VirtLines virt_lines
Definition: decoration.h:40
DecorRange::ns_id
uint64_t ns_id
Definition: decoration.h:78
kVTRightAlign
@ kVTRightAlign
Definition: decoration.h:17
DecorRange::start_row
int start_row
Definition: decoration.h:70
HlMode
HlMode
Definition: decoration.h:22
Decoration::virt_text_hide
bool virt_text_hide
Definition: decoration.h:47
Decoration::sign_hl_id
int sign_hl_id
Definition: decoration.h:56
DecorRange
Definition: decoration.h:69
MarkTreeIter
Definition: marktree.h:27
VirtTextChunk
Definition: extmark_defs.h:7
Decoration::hl_mode
HlMode hl_mode
Definition: decoration.h:44
active
bool active
Definition: edit.c:219
DecorState::buf
buf_T * buf
Definition: decoration.h:85
kHlModeUnknown
@ kHlModeUnknown
Definition: decoration.h:23
Decoration::priority
DecorPriority priority
Definition: decoration.h:52
DecorState::conceal
bool conceal
Definition: decoration.h:92
extmark_defs.h
kvec_t
typedef kvec_t(VirtTextChunk) VirtText
EXTERN
#define EXTERN
Definition: macros.h:9
Decoration::conceal_char
int conceal_char
Definition: decoration.h:62
line
void const char * line
Definition: eval.c:6881
DecorRange::virt_text_owned
bool virt_text_owned
Definition: decoration.h:76
char_u
unsigned char char_u
Definition: types.h:12
DecorState::eol_col
int eol_col
Definition: decoration.h:90
DecorRange::start_col
int start_col
Definition: decoration.h:71
DecorState::conceal_attr
int conceal_attr
Definition: decoration.h:94
file_buffer
Definition: buffer_defs.h:521
Decoration::virt_text
VirtText virt_text
Definition: decoration.h:39
buffer_defs.h
DecorRange::mark_id
uint64_t mark_id
Definition: decoration.h:79
kVTWinCol
@ kVTWinCol
Definition: decoration.h:16
kVTOverlay
@ kVTOverlay
Definition: decoration.h:15
DecorRange::end_col
int end_col
Definition: decoration.h:73
Decoration::hl_id
int hl_id
Definition: decoration.h:42
kHlModeReplace
@ kHlModeReplace
Definition: decoration.h:24
DecorState::conceal_char
int conceal_char
Definition: decoration.h:93
kHlModeCombine
@ kHlModeCombine
Definition: decoration.h:25
DecorState::col_until
int col_until
Definition: decoration.h:88
Decoration
Definition: decoration.h:38
pos.h