robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
a8da01f8e6
master
1#pragma once 2 3#include <stdbool.h> 4#include <stddef.h> // IWYU pragma: keep 5#include <stdint.h> 6 7#include "klib/kvec.h" 8#include "nvim/decoration_defs.h" // IWYU pragma: keep 9#include "nvim/macros_defs.h" 10#include "nvim/marktree_defs.h" 11#include "nvim/pos_defs.h" // IWYU pragma: keep 12#include "nvim/sign_defs.h" // IWYU pragma: keep 13#include "nvim/types_defs.h" 14 15// actual Decor* data is in decoration_defs.h 16 17/// Keep in sync with VirtTextPos in decoration_defs.h 18EXTERN const char * const virt_text_pos_str []INIT (= {"eol" ,"eol_right_align" ,"inline" , 19"overlay" ,"right_align" ,"win_col" }); 20 21/// Keep in sync with HlMode in decoration_defs.h 22EXTERN const char * const hl_mode_str []INIT (= {"" ,"replace" ,"combine" ,"blend" }); 23 24typedef enum { 25kDecorKindHighlight , 26kDecorKindSign , 27kDecorKindVirtText , 28kDecorKindVirtLines , 29kDecorKindUIWatched , 30}DecorRangeKindEnum ; 31 32typedef uint8_t DecorRangeKind ; 33 34typedef struct { 35int start_row ; 36int start_col ; 37int end_row ; 38int end_col ; 39int ordering ;///< range insertion order 40DecorPriorityInternal priority_internal ; 41bool owned ;///< ephemeral decoration, free memory immediately 42DecorRangeKind kind ; 43// next pointers MUST NOT be used, these are separate ranges 44// vt->next could be pointing to freelist memory at this point 45union { 46DecorSignHighlight sh ; 47DecorVirtText * vt ; 48struct { 49uint32_t ns_id ; 50uint32_t mark_id ; 51VirtTextPos pos ; 52 }ui ; 53 }data ; 54int attr_id ;///< cached lookup of inl.hl_id if it was a highlight 55/// Screen column to draw the virtual text. 56/// When -1, it should be drawn on the current screen line after deciding where. 57/// When -3, it may be drawn at a position yet to be assigned. 58/// When -10, it has just been added. 59/// When INT_MIN, it should no longer be drawn. 60int draw_col ; 61}DecorRange ; 62 63/// DecorRange can be removed from `DecorState` list in any order, 64/// so we track available slots using a freelist (with `next_free_i`). 65/// The list head is in `DecorState.free_slot_i`. 66typedef union { 67DecorRange range ; 68int next_free_i ; 69}DecorRangeSlot ; 70 71typedef struct { 72MarkTreeIter itr [1 ]; 73kvec_t (DecorRangeSlot )slots ; 74kvec_t (int )ranges_i ; 75/// Indices in [0; current_end) of `ranges_i` point to ranges that start 76/// before current position. Sorted by priority and order of insertion. 77int current_end ; 78/// Indices in [future_begin, kv_size(ranges_i)) of `ranges_i` point to 79/// ranges that start after current position. Sorted by starting position. 80int future_begin ; 81/// Head of DecorRangeSlot freelist. -1 if none are freed. 82int free_slot_i ; 83/// Index for keeping track of range insertion order. 84int new_range_ordering ; 85win_T * win ; 86int top_row ; 87int row ; 88int col_last ; 89int current ; 90int current_hl_eol ;///< "current" limited to ranges with "hl_eol" 91int eol_col ; 92 93int conceal ; 94schar_T conceal_char ; 95int conceal_attr ; 96 97TriState spell ; 98 99bool running_decor_provider ; 100bool itr_valid ; 101}DecorState ; 102 103EXTERN DecorState decor_state INIT (= {0 }); 104// TODO(bfredl): These should maybe be per-buffer, so that all resources 105// associated with a buffer can be freed when the buffer is unloaded. 106EXTERN kvec_t (DecorSignHighlight )decor_items INIT (= KV_INITIAL_VALUE ); 107 108#include "decoration.h.generated.h" 109#include "decoration.h.inline.generated.h" 110 111static inline int decor_redraw_col (win_T * wp ,int col ,int win_col ,bool hidden ,DecorState * state , 112int max_col_last ) 113FUNC_ATTR_ALWAYS_INLINE 114{ 115if (col <=state -> col_last ) { 116return state -> current ; 117 } 118return decor_redraw_col_impl (wp ,col ,win_col ,hidden ,state ,max_col_last ); 119}