docs: add comments for DecorRangeSlot struct

This commit is contained in:
vanaigr
2024-11-09 23:10:49 -06:00
parent 3abd7ed4a4
commit c57397f981

View File

@@ -58,6 +58,9 @@ typedef struct {
int draw_col; int draw_col;
} DecorRange; } DecorRange;
/// DecorRange can be removed from `DecorState` list in any order,
/// so we track available slots using a freelist (with `next_free_i`).
/// The list head is in `DecorState.free_slot_i`.
typedef union { typedef union {
DecorRange range; DecorRange range;
int next_free_i; int next_free_i;
@@ -67,14 +70,16 @@ typedef struct {
MarkTreeIter itr[1]; MarkTreeIter itr[1];
kvec_t(DecorRangeSlot) slots; kvec_t(DecorRangeSlot) slots;
kvec_t(int) ranges_i; kvec_t(int) ranges_i;
/// Indices in [0; current_end) range of `ranges_i` point to ranges that start before the /// Indices in [0; current_end) of `ranges_i` point to ranges that start
/// current position and are sorted by priority and order of insertion. /// before current position. Sorted by priority and order of insertion.
int current_end; int current_end;
/// Indices in [future_begin, kv_size(ranges_i)) range of `ranges_i` point to ranges that /// Indices in [future_begin, kv_size(ranges_i)) of `ranges_i` point to
/// start after the current position and are sorted by starting position. /// ranges that start after current position. Sorted by starting position.
int future_begin; int future_begin;
int free_slot_i; ///< Index of the last freed slot. /// Head of DecorRangeSlot freelist. -1 if none are freed.
int new_range_ordering; ///< Index for keeping track of range insertion order. int free_slot_i;
/// Index for keeping track of range insertion order.
int new_range_ordering;
win_T *win; win_T *win;
int top_row; int top_row;
int row; int row;
@@ -91,7 +96,7 @@ typedef struct {
bool running_decor_provider; bool running_decor_provider;
} DecorState; } DecorState;
EXTERN DecorState decor_state INIT( = { .free_slot_i = -1 }); EXTERN DecorState decor_state INIT( = { 0 });
// TODO(bfredl): These should maybe be per-buffer, so that all resources // TODO(bfredl): These should maybe be per-buffer, so that all resources
// associated with a buffer can be freed when the buffer is unloaded. // associated with a buffer can be freed when the buffer is unloaded.
EXTERN kvec_t(DecorSignHighlight) decor_items INIT( = KV_INITIAL_VALUE); EXTERN kvec_t(DecorSignHighlight) decor_items INIT( = KV_INITIAL_VALUE);