aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/grid_defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/grid_defs.h')
-rw-r--r--src/nvim/grid_defs.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/nvim/grid_defs.h b/src/nvim/grid_defs.h
new file mode 100644
index 0000000000..964a71de62
--- /dev/null
+++ b/src/nvim/grid_defs.h
@@ -0,0 +1,59 @@
+#ifndef NVIM_GRID_DEFS_H
+#define NVIM_GRID_DEFS_H
+
+#include <stdint.h>
+
+#include "nvim/types.h"
+
+#define MAX_MCO 6 // maximum value for 'maxcombine'
+
+// The characters and attributes drawn on grids.
+typedef char_u schar_T[(MAX_MCO+1) * 4 + 1];
+typedef int16_t sattr_T;
+
+/// ScreenGrid represents a resizable rectuangular grid displayed by UI clients.
+///
+/// ScreenLines contains the UTF-8 text that is currently displayed on the grid.
+/// It is stored as a single block of cells. When redrawing a part of the grid,
+/// the new state can be compared with the existing state of the grid. This way
+/// we can avoid sending bigger updates than neccessary to the Ul layer.
+///
+/// Screen cells are stored as NUL-terminated UTF-8 strings, and a cell can
+/// contain up to MAX_MCO composing characters after the base character.
+/// The composing characters are to be drawn on top of the original character.
+/// The content after the NUL is not defined (so comparison must be done a
+/// single cell at a time). Double-width characters are stored in the left cell,
+/// and the right cell should only contain the empty string. When a part of the
+/// screen is cleared, the cells should be filled with a single whitespace char.
+///
+/// ScreenAttrs[] contains the highlighting attribute for each cell.
+/// LineOffset[n] is the offset from ScreenLines[] and ScreenAttrs[] for the
+/// start of line 'n'. These offsets are in general not linear, as full screen
+/// scrolling is implemented by rotating the offsets in the LineOffset array.
+/// LineWraps[] is an array of boolean flags indicating if the screen line wraps
+/// to the next line. It can only be true if a window occupies the entire screen
+/// width.
+typedef struct {
+ handle_T handle;
+
+ schar_T *ScreenLines;
+ sattr_T *ScreenAttrs;
+ unsigned *LineOffset;
+ char_u *LineWraps;
+
+ // the size of the allocated grid
+ int Rows;
+ int Columns;
+
+ // offsets for the grid relative to the global screen
+ int OffsetRow;
+ int OffsetColumn;
+
+ // the size expected to be allocated to the internal grid
+ int internal_rows;
+ int internal_columns;
+
+ int was_resized;
+} ScreenGrid;
+
+#endif // NVIM_GRID_DEFS_H