neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

statusline_defs.h (4671B)


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