buffer.h
Go to the documentation of this file.
1 #ifndef NVIM_BUFFER_H
2 #define NVIM_BUFFER_H
3 
4 #include "nvim/vim.h"
5 #include "nvim/window.h"
6 #include "nvim/pos.h" // for linenr_T
7 #include "nvim/ex_cmds_defs.h" // for exarg_T
8 #include "nvim/screen.h" // for StlClickRecord
9 #include "nvim/func_attr.h"
10 #include "nvim/eval.h"
11 #include "nvim/macros.h"
12 
13 // Values for buflist_getfile()
15  GETF_SETMARK = 0x01, // set pcmark before jumping
16  GETF_ALT = 0x02, // jumping to alternate file (not buf num)
17  GETF_SWITCH = 0x04, // respect 'switchbuf' settings when jumping
18 };
19 
20 // Return values of getfile()
22  GETFILE_ERROR = 1, // normal error
23  GETFILE_NOT_WRITTEN = 2, // "not written" error
24  GETFILE_SAME_FILE = 0, // success, same file
25  GETFILE_OPEN_OTHER = -1, // success, opened another file
27 };
28 
29 // Values for buflist_new() flags
30 enum bln_values {
31  BLN_CURBUF = 1, // May re-use curbuf for new buffer
32  BLN_LISTED = 2, // Put new buffer in buffer list
33  BLN_DUMMY = 4, // Allocating dummy buffer
34  BLN_NEW = 8, // create a new buffer
35  BLN_NOOPT = 16, // Don't copy options to existing buffer
36 };
37 
38 // Values for action argument for do_buffer()
40  DOBUF_GOTO = 0, // go to specified buffer
41  DOBUF_SPLIT = 1, // split window and go to specified buffer
42  DOBUF_UNLOAD = 2, // unload specified buffer(s)
43  DOBUF_DEL = 3, // delete specified buffer(s) from buflist
44  DOBUF_WIPE = 4, // delete specified buffer(s) really
45 };
46 
47 // Values for start argument for do_buffer()
49  DOBUF_CURRENT = 0, // "count" buffer from current buffer
50  DOBUF_FIRST = 1, // "count" buffer from first buffer
51  DOBUF_LAST = 2, // "count" buffer from last buffer
52  DOBUF_MOD = 3, // "count" mod. buffer from current buffer
53 };
54 
55 // flags for buf_freeall()
56 enum bfa_values {
57  BFA_DEL = 1, // buffer is going to be deleted
58  BFA_WIPE = 2, // buffer is going to be wiped out
59  BFA_KEEP_UNDO = 4, // do not free undo information
60 };
61 
62 #ifdef INCLUDE_GENERATED_DECLARATIONS
63 # include "buffer.h.generated.h"
64 #endif
65 
66 static inline void buf_set_changedtick(buf_T *const buf,
67  const varnumber_T changedtick)
69 
74 static inline void buf_set_changedtick(buf_T *const buf,
75  const varnumber_T changedtick)
76 {
77  typval_T old_val = buf->changedtick_di.di_tv;
78 
79 #ifndef NDEBUG
80  dictitem_T *const changedtick_di = tv_dict_find(
81  buf->b_vars, S_LEN("changedtick"));
82  assert(changedtick_di != NULL);
83  assert(changedtick_di->di_tv.v_type == VAR_NUMBER);
84  assert(changedtick_di->di_tv.v_lock == VAR_FIXED);
85  // For some reason formatc does not like the below.
86 # ifndef UNIT_TESTING_LUA_PREPROCESSING
87  assert(changedtick_di->di_flags == (DI_FLAGS_RO|DI_FLAGS_FIX));
88 # endif
89  assert(changedtick_di == (dictitem_T *)&buf->changedtick_di);
90 #endif
91  buf->changedtick_di.di_tv.vval.v_number = changedtick;
92 
93  if (tv_dict_is_watched(buf->b_vars)) {
95  (char *)buf->changedtick_di.di_key,
96  &buf->changedtick_di.di_tv,
97  &old_val);
98  }
99 }
100 
101 static inline varnumber_T buf_get_changedtick(const buf_T *const buf)
104 
110 static inline varnumber_T buf_get_changedtick(const buf_T *const buf)
111 {
112  return buf->changedtick_di.di_tv.vval.v_number;
113 }
114 
115 static inline void buf_inc_changedtick(buf_T *const buf)
117 
123 static inline void buf_inc_changedtick(buf_T *const buf)
124 {
125  buf_set_changedtick(buf, buf_get_changedtick(buf) + 1);
126 }
127 
128 #endif // NVIM_BUFFER_H
dobuf_start_values
Definition: buffer.h:48
Definition: buffer.h:17
Definition: buffer.h:44
Definition: buffer.h:57
getf_retvalues
Definition: buffer.h:21
Definition: coverity-model.c:39
Definition: buffer.h:31
Structure that holds an internal variable value.
Definition: typval.h:125
#define S_LEN(s)
Definition: macros.h:29
ChangedtickDictItem changedtick_di
Definition: buffer_defs.h:514
Definition: buffer.h:40
return NULL
Definition: eval.c:23440
Definition: buffer.h:43
getf_values
Definition: buffer.h:14
dict_T * b_vars
b: scope dictionary.
Definition: buffer_defs.h:767
Definition: buffer.h:35
bln_values
Definition: buffer.h:30
Definition: buffer.h:24
Read-only value.
Definition: typval.h:225
Number, .v_number is used.
Definition: typval.h:113
void tv_dict_watcher_notify(dict_T *const dict, const char *const key, typval_T *const newtv, typval_T *const oldtv) FUNC_ATTR_NONNULL_ARG(1
static int REAL_FATTR_WARN_UNUSED_RESULT
Definition: typval_encode.c.h:295
Definition: buffer.h:26
#define REAL_FATTR_NONNULL_ALL
Definition: func_attr.h:183
dobuf_action_values
Definition: buffer.h:39
Definition: buffer.h:59
Definition: buffer.h:50
Definition: buffer.h:42
assert(len >=0)
Definition: buffer_defs.h:480
Definition: buffer.h:33
char *const buf
Definition: encode.c:231
Definition: buffer.h:49
dictitem_T * tv_dict_find(const dict_T *const d, const char *const key, const ptrdiff_t len) FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
Definition: typval.c:1413
Definition: buffer.h:32
Definition: buffer.h:58
Definition: buffer.h:41
Definition: buffer.h:22
Definition: buffer.h:51
static int REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE
Definition: typval_encode.c.h:258
int64_t varnumber_T
Type used for VimL VAR_NUMBER values.
Definition: typval.h:28
bfa_values
Definition: buffer.h:56
Definition: buffer.h:16
#define REAL_FATTR_PURE
Definition: func_attr.h:163
Locked forever.
Definition: typval.h:107
Definition: buffer.h:52
Definition: buffer.h:15
Fixed value: cannot be :unlet or remove()d.
Definition: typval.h:227
Definition: buffer.h:34
Definition: buffer.h:25
Definition: buffer.h:23