robin/laufey

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

Justin M. Keyesrefactor(ctx): drop aucmd_prepbuf/aucmd_restbuf #406920f1e0a7900

master
2.3 KiB61 linesraw
1#pragma once
2
3#include <stdbool.h>
4#include <stddef.h>
5#include <stdint.h>
6
7#include "nvim/buffer_defs.h"
8#include "nvim/ex_cmds_defs.h"
9
10#include "auevents_enum.generated.h"
11
12typedef struct {
13  size_t refcount;          ///< Reference count (freed when reaches zero)
14  char *pat;                ///< Pattern as typed
15  regprog_T *reg_prog;      ///< Compiled regprog for pattern
16  int group;                ///< Group ID
17  int patlen;               ///< strlen() of pat
18  int buflocal_nr;          ///< !=0 for buffer-local AutoPat
19  char allow_dirs;          ///< Pattern may match whole path
20} AutoPat;
21
22typedef struct {
23  AutoPat *pat;             ///< Pattern reference (NULL when autocmd was removed)
24  int64_t id;               ///< ID used for uniquely tracking an autocmd
25  char *desc;               ///< Description for the autocmd
26  char *handler_cmd;        ///< Handler Ex command (NULL if handler is a function).
27  Callback handler_fn;      ///< Handler callback (ignored if `handler_cmd` is not NULL).
28  sctx_T script_ctx;        ///< Script context where it is defined
29  bool once;                ///< "One shot": removed after execution
30  bool nested;              ///< If autocommands nest here
31} AutoCmd;
32
33/// Struct used to keep status while executing autocommands for an event.
34typedef struct AutoPatCmd_S AutoPatCmd;
35struct AutoPatCmd_S {
36  AutoPat *lastpat;         ///< Last matched AutoPat
37  size_t auidx;             ///< Current autocmd index to execute
38  size_t ausize;            ///< Saved AutoCmd vector size
39  char *afile_orig;         ///< Unexpanded <afile>
40  char *fname;              ///< Fname to match with
41  char *sfname;             ///< Sfname to match with
42  char *tail;               ///< Tail of fname
43  int group;                ///< Group being used
44  event_T event;            ///< Current event
45  sctx_T script_ctx;        ///< Script context where it is defined
46  int arg_bufnr;            ///< Initially equal to <abuf>, set to zero when buf is deleted
47  Object *data;             ///< Arbitrary data
48  AutoPatCmd *next;         ///< Chain of active apc-s for auto-invalidation
49};
50
51typedef kvec_t(AutoCmd) AutoCmdVec;
52
53typedef struct {
54  event_T event;
55  char *fname;
56  char *fname_io;
57  Buffer buf;
58  int group;
59  exarg_T *eap;
60  Object *data;
61} AutoCmdEvent;  // Used for "deferred" events, but can represent any event.