aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ugrid.h
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-08-26 09:07:04 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-09-06 09:18:52 -0300
commitf5c5cdb306704e40019fb0eb9457e64bda8ee7cc (patch)
tree07bc347ee6f3af269710e42e3d40aa3c06190489 /src/nvim/ugrid.h
parentcb9ae4e373af5d436499531698cec96ffc9bc39d (diff)
downloadrneovim-f5c5cdb306704e40019fb0eb9457e64bda8ee7cc.tar.gz
rneovim-f5c5cdb306704e40019fb0eb9457e64bda8ee7cc.tar.bz2
rneovim-f5c5cdb306704e40019fb0eb9457e64bda8ee7cc.zip
tui: Move screen state tracking to new "ugrid" module
The ugrid module implements a unicode "drawing" grid and is used to store TUI screen state. Later this module will be reused in other layers.
Diffstat (limited to 'src/nvim/ugrid.h')
-rw-r--r--src/nvim/ugrid.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/nvim/ugrid.h b/src/nvim/ugrid.h
new file mode 100644
index 0000000000..e41461fa16
--- /dev/null
+++ b/src/nvim/ugrid.h
@@ -0,0 +1,40 @@
+#ifndef NVIM_UGRID_H
+#define NVIM_UGRID_H
+
+#include "nvim/ui.h"
+
+typedef struct ucell UCell;
+typedef struct ugrid UGrid;
+
+struct ucell {
+ char data[7];
+ 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})
+
+#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