aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/statusline_defs.h
blob: c1a54f4f54f1e744e62e14153df15bc18bf6763e (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once

#include <stdbool.h>
#include <stddef.h>

#include "nvim/fold_defs.h"
#include "nvim/macros_defs.h"
#include "nvim/os/os_defs.h"
#include "nvim/sign_defs.h"

/// Status line click definition
typedef struct {
  enum {
    kStlClickDisabled = 0,  ///< Clicks to this area are ignored.
    kStlClickTabSwitch,     ///< Switch to the given tab.
    kStlClickTabClose,      ///< Close given tab.
    kStlClickFuncRun,       ///< Run user function.
  } type;      ///< Type of the click.
  int tabnr;   ///< Tab page number.
  char *func;  ///< Function to run.
} StlClickDefinition;

/// Used for tabline clicks
typedef struct {
  StlClickDefinition def;  ///< Click definition.
  const char *start;       ///< Location where region starts.
} StlClickRecord;

/// Used for highlighting in the status line.
typedef struct stl_hlrec stl_hlrec_t;
struct stl_hlrec {
  char *start;
  int userhl;                   // 0: no HL, 1-9: User HL, < 0 for syn ID
};

/// Used for building the status line.
typedef struct stl_item stl_item_t;
struct stl_item {
  // Where the item starts in the status line output buffer
  char *start;
  // Function to run for ClickFunc items.
  char *cmd;
  // The minimum width of the item
  int minwid;
  // The maximum width of the item
  int maxwid;
  enum {
    Normal,
    Empty,
    Group,
    Separate,
    Highlight,
    TabPage,
    ClickFunc,
    Trunc,
  } type;
};

/// Struct to hold info for 'statuscolumn'
typedef struct statuscol statuscol_T;

struct statuscol {
  int width;                           ///< width of the status column
  int cur_attr;                        ///< current attributes in text
  int num_attr;                        ///< default highlight attr
  int sign_cul_id;                     ///< cursorline sign highlight id
  int truncate;                        ///< truncated width
  bool draw;                           ///< whether to draw the statuscolumn
  bool use_cul;                        ///< whether to use cursorline attrs
  char text[MAXPATHL];                 ///< text in status column
  char *textp;                         ///< current position in text
  char *text_end;                      ///< end of text (the NUL byte)
  stl_hlrec_t *hlrec;                  ///< highlight groups
  stl_hlrec_t *hlrecp;                 ///< current highlight group
  foldinfo_T foldinfo;                 ///< fold information
  SignTextAttrs *sattrs;               ///< sign attributes
};