robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
43f3c4a48f
master
1#pragma once 2 3#include <stdbool.h> 4#include <stddef.h> 5#include <stdint.h> 6 7#include "nvim/pos_defs.h" 8#include "nvim/types_defs.h" 9 10enum { 11kZIndexDefaultGrid = 0 , 12kZIndexFloatDefault = 50 , 13kZIndexPopupMenu = 100 , 14kZIndexMessages = 200 , 15kZIndexCmdlinePopupMenu = 250 , 16}; 17 18/// ScreenGrid represents a resizable rectuangular grid displayed by UI clients. 19/// 20/// chars[] contains the UTF-8 text that is currently displayed on the grid. 21/// It is stored as a single block of cells. When redrawing a part of the grid, 22/// the new state can be compared with the existing state of the grid. This way 23/// we can avoid sending bigger updates than necessary to the Ul layer. 24/// 25/// Screen cells are stored as NUL-terminated UTF-8 strings, and a cell can 26/// contain composing characters as many as fits in MAX_SCHAR_SIZE-1 bytes 27/// The composing characters are to be drawn on top of the original character. 28/// The content after the NUL is not defined (so comparison must be done a 29/// single cell at a time). Double-width characters are stored in the left cell, 30/// and the right cell should only contain the empty string. When a part of the 31/// screen is cleared, the cells should be filled with a single whitespace char. 32/// 33/// attrs[] contains the highlighting attribute for each cell. 34/// 35/// vcols[] contains the virtual columns in the line. -1 means not available 36/// or before buffer text. 37/// -2 or -3 means in fold column and a mouse click should: 38/// -2: open a fold 39/// -3: close a fold 40/// 41/// line_offset[n] is the offset from chars[], attrs[] and vcols[] for the start 42/// of line 'n'. These offsets are in general not linear, as full screen scrolling 43/// is implemented by rotating the offsets in the line_offset array. 44typedef struct ScreenGrid ScreenGrid ; 45struct ScreenGrid { 46handle_T handle ; 47 48schar_T * chars ; 49sattr_T * attrs ; 50colnr_T * vcols ; 51size_t * line_offset ; 52 53// last column that was drawn (not cleared with the default background). 54// only used when "throttled" is set. Not allocated by grid_alloc! 55int * dirty_col ; 56 57// the size of the allocated grid. 58int rows ; 59int cols ; 60 61// The state of the grid is valid. Otherwise it needs to be redrawn. 62bool valid ; 63 64// only draw internally and don't send updates yet to the compositor or 65// external UI. 66bool throttled ; 67 68// whether the compositor should blend the grid with the background grid 69bool blending ; 70 71// whether the grid interacts with mouse events. 72bool mouse_enabled ; 73 74// z-index: the order in the stack of grids. 75int zindex ; 76 77// Below is state owned by the compositor. Should generally not be set/read 78// outside this module, except for specific compatibility hacks 79 80// position of the grid on the composed screen. 81int comp_row ; 82int comp_col ; 83 84// Requested width and height of the grid upon resize. Used by 85// `ui_compositor` to correctly determine which regions need to 86// be redrawn. 87int comp_width ; 88int comp_height ; 89 90// z-index of the grid. Grids with higher index is draw on top. 91// default_grid.comp_index is always zero. 92size_t comp_index ; 93 94// compositor should momentarily ignore the grid. Used internally when 95// moving around grids etc. 96bool comp_disabled ; 97 98// need to resend win_float_pos or similar due to comp_index change 99bool pending_comp_index_update ; 100}; 101 102#define SCREEN_GRID_INIT { 0, NULL, NULL, NULL, NULL, NULL, 0, 0, false, \ 103 false, false, true, 0, \ 104 0, 0, 0, 0, 0, false, true } 105 106/// Represents the position of a viewport within a ScreenGrid 107typedef struct { 108ScreenGrid * target ; 109int row_offset ; 110int col_offset ; 111}GridView ; 112 113typedef struct { 114int args [3 ]; 115int icell ; 116int ncells ; 117int coloff ; 118int cur_attr ; 119int clear_width ; 120bool wrap ; 121}GridLineEvent ;