robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
4.8 KiB120 linesraw
1#pragma once
2
3#include <stdbool.h>
4
5#include "nvim/fold_defs.h"
6#include "nvim/pos_defs.h"
7#include "nvim/sign_defs.h"
8
9/// 'statusline' item flags
10typedef enum {
11  STL_FILEPATH        = 'f',  ///< Path of file in buffer.
12  STL_FULLPATH        = 'F',  ///< Full path of file in buffer.
13  STL_FILENAME        = 't',  ///< Last part (tail) of file path.
14  STL_COLUMN          = 'c',  ///< Column og cursor.
15  STL_VIRTCOL         = 'v',  ///< Virtual column.
16  STL_VIRTCOL_ALT     = 'V',  ///< - with 'if different' display.
17  STL_LINE            = 'l',  ///< Line number of cursor.
18  STL_NUMLINES        = 'L',  ///< Number of lines in buffer.
19  STL_BUFNO           = 'n',  ///< Current buffer number.
20  STL_KEYMAP          = 'k',  ///< 'keymap' when active.
21  STL_OFFSET          = 'o',  ///< Offset of character under cursor.
22  STL_OFFSET_X        = 'O',  ///< - in hexadecimal.
23  STL_BYTEVAL         = 'b',  ///< Byte value of character.
24  STL_BYTEVAL_X       = 'B',  ///< - in hexadecimal.
25  STL_ROFLAG          = 'r',  ///< Readonly flag.
26  STL_ROFLAG_ALT      = 'R',  ///< - other display.
27  STL_HELPFLAG        = 'h',  ///< Window is showing a help file.
28  STL_HELPFLAG_ALT    = 'H',  ///< - other display.
29  STL_FILETYPE        = 'y',  ///< 'filetype'.
30  STL_FILETYPE_ALT    = 'Y',  ///< - other display.
31  STL_PREVIEWFLAG     = 'w',  ///< Window is showing the preview buf.
32  STL_PREVIEWFLAG_ALT = 'W',  ///< - other display.
33  STL_MODIFIED        = 'm',  ///< Modified flag.
34  STL_MODIFIED_ALT    = 'M',  ///< - other display.
35  STL_QUICKFIX        = 'q',  ///< Quickfix window description.
36  STL_PERCENTAGE      = 'p',  ///< Percentage through file.
37  STL_ALTPERCENT      = 'P',  ///< Percentage as TOP BOT ALL or NN%.
38  STL_ARGLISTSTAT     = 'a',  ///< Argument list status as (x of y).
39  STL_PAGENUM         = 'N',  ///< Page number (when printing).
40  STL_SHOWCMD         = 'S',  ///< 'showcmd' buffer
41  STL_FOLDCOL         = 'C',  ///< Fold column for 'statuscolumn'
42  STL_SIGNCOL         = 's',  ///< Sign column for 'statuscolumn'
43  STL_VIM_EXPR        = '{',  ///< Start of expression to substitute.
44  STL_SEPARATE        = '=',  ///< Separation between alignment sections.
45  STL_TRUNCMARK       = '<',  ///< Truncation mark if line is too long.
46  STL_USER_HL         = '*',  ///< Highlight from (User)1..9 or 0.
47  STL_HIGHLIGHT       = '#',  ///< Highlight name.
48  STL_HIGHLIGHT_COMB  = '$',  ///< Highlight name (combining previous attrs).
49  STL_TABPAGENR       = 'T',  ///< Tab page label nr.
50  STL_TABCLOSENR      = 'X',  ///< Tab page close nr.
51  STL_CLICK_FUNC      = '@',  ///< Click region start.
52} StlFlag;
53
54/// Status line click definition
55typedef struct {
56  enum {
57    kStlClickDisabled = 0,  ///< Clicks to this area are ignored.
58    kStlClickTabSwitch,     ///< Switch to the given tab.
59    kStlClickTabClose,      ///< Close given tab.
60    kStlClickFuncRun,       ///< Run user function.
61  } type;      ///< Type of the click.
62  int tabnr;   ///< Tab page number.
63  char *func;  ///< Function to run.
64} StlClickDefinition;
65
66typedef struct {
67  StlClickDefinition *def;  ///< Click definition.
68  size_t size;              ///< Click definition size.
69} StcClick;
70
71/// Used for tabline clicks
72typedef struct {
73  StlClickDefinition def;  ///< Click definition.
74  const char *start;       ///< Location where region starts.
75} StlClickRecord;
76
77/// Used for highlighting in the status line.
78typedef struct stl_hlrec stl_hlrec_t;
79struct stl_hlrec {
80  char *start;             ///< Where the item starts in the status line output buffer
81  int userhl;              ///< 0: no HL, 1-9: User HL, < 0 for syn ID
82  StlFlag item;            ///< Item flag belonging to highlight (used for 'statuscolumn')
83};
84
85/// Used for building the status line.
86typedef struct stl_item stl_item_t;
87struct stl_item {
88  char *start;             ///< Where the item starts in the status line output buffer
89  char *cmd;               ///< Function to run for ClickFunc items
90  int minwid;              ///< The minimum width of the item
91  int maxwid;              ///< The maximum width of the item
92  enum {
93    Disabled,
94    Normal,
95    NormalEmpty,
96    Group,
97    Separate,
98    Trunc,
99    Expression,
100    Highlight,
101    HighlightCombining,
102    HighlightScope,
103    HighlightSign,
104    HighlightFold,
105    TabPage,
106    ClickFunc,
107  } type;
108};
109
110/// Struct to hold info for 'statuscolumn'
111typedef struct {
112  int width;                           ///< width of the status column
113  linenr_T lnum;                       ///< buffer line being drawn
114  int sign_cul_id;                     ///< cursorline sign highlight id
115  bool draw;                           ///< whether to draw the statuscolumn
116  stl_hlrec_t *hlrec;                  ///< highlight groups
117  foldinfo_T foldinfo;                 ///< fold information
118  colnr_T fold_vcol[9];                ///< vcol array filled for fold item
119  SignTextAttrs *sattrs;               ///< sign attributes
120} statuscol_T;