aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ugrid.h
blob: 268362bf1ba7007d53aa2a18d8f4acbfc3dee333 (plain) (blame)
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
#ifndef NVIM_UGRID_H
#define NVIM_UGRID_H

#include "nvim/ui.h"
#include "nvim/globals.h"

typedef struct ucell UCell;
typedef struct ugrid UGrid;

struct ucell {
  char data[6 * MAX_MCO + 1];
  HlAttrs attrs;
};

struct ugrid {
  int top, bot, left, right;
  int row, col;
  int bg, fg;
  int width, height;
  HlAttrs attrs;
  UCell **cells;
};

#define EMPTY_ATTRS ((HlAttrs){ false, false, false, false, false, -1, -1, -1 })

#define UGRID_FOREACH_CELL(grid, top, bot, left, right, code) \
  do { \
    for (int row = top; row <= bot; row++) { \
      UCell *row_cells = (grid)->cells[row]; \
      for (int col = left; col <= right; col++) { \
        UCell *cell = row_cells + col; \
        (void)(cell); \
        code; \
      } \
    } \
  } while (0)

#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ugrid.h.generated.h"
#endif
#endif  // NVIM_UGRID_H