neovim

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

buffer.h (3268B)


      1 #pragma once
      2 
      3 #include <stdint.h>
      4 
      5 #include "nvim/buffer_defs.h"  // IWYU pragma: keep
      6 #include "nvim/eval/typval_defs.h"
      7 #include "nvim/ex_cmds_defs.h"  // IWYU pragma: keep
      8 #include "nvim/gettext_defs.h"  // IWYU pragma: keep
      9 #include "nvim/macros_defs.h"
     10 #include "nvim/marktree_defs.h"
     11 #include "nvim/types_defs.h"
     12 
     13 /// Values for buflist_getfile()
     14 enum getf_values {
     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()
     21 enum getf_retvalues {
     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
     26  GETFILE_UNUSED      = 8,
     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  // BLN_DUMMY_OK = 32,  // also find an existing dummy buffer
     37  // BLN_REUSE = 64,   // may re-use number from buf_reuse
     38  BLN_NOCURWIN = 128,  ///< buffer is not associated with curwin
     39 };
     40 
     41 /// Values for action argument for do_buffer_ext() and close_buffer()
     42 enum dobuf_action_values {
     43  DOBUF_GOTO   = 0,  ///< go to specified buffer
     44  DOBUF_SPLIT  = 1,  ///< split window and go to specified buffer
     45  DOBUF_UNLOAD = 2,  ///< unload specified buffer(s)
     46  DOBUF_DEL    = 3,  ///< delete specified buffer(s) from buflist
     47  DOBUF_WIPE   = 4,  ///< delete specified buffer(s) really
     48 };
     49 
     50 /// Values for start argument for do_buffer_ext()
     51 enum dobuf_start_values {
     52  DOBUF_CURRENT = 0,  ///< "count" buffer from current buffer
     53  DOBUF_FIRST   = 1,  ///< "count" buffer from first buffer
     54  DOBUF_LAST    = 2,  ///< "count" buffer from last buffer
     55  DOBUF_MOD     = 3,  ///< "count" mod. buffer from current buffer
     56 };
     57 
     58 /// Values for flags argument of do_buffer_ext()
     59 enum dobuf_flags_value {
     60  DOBUF_FORCEIT  = 1,  ///< :cmd!
     61  DOBUF_SKIPHELP = 4,  ///< skip or keep help buffers depending on b_help of the
     62                       ///< starting buffer
     63 };
     64 
     65 /// flags for buf_freeall()
     66 enum bfa_values {
     67  BFA_DEL          = 1,  ///< buffer is going to be deleted
     68  BFA_WIPE         = 2,  ///< buffer is going to be wiped out
     69  BFA_KEEP_UNDO    = 4,  ///< do not free undo information
     70  BFA_IGNORE_ABORT = 8,  ///< do not abort for aborting()
     71 };
     72 
     73 EXTERN char *msg_loclist INIT( = N_("[Location List]"));
     74 EXTERN char *msg_qflist INIT( = N_("[Quickfix List]"));
     75 
     76 #include "buffer.h.generated.h"
     77 #include "buffer.h.inline.generated.h"
     78 
     79 /// Get b:changedtick value
     80 ///
     81 /// Faster then querying b:.
     82 ///
     83 /// @param[in]  buf  Buffer to get b:changedtick from.
     84 static inline varnumber_T buf_get_changedtick(const buf_T *const buf)
     85  FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE
     86  FUNC_ATTR_WARN_UNUSED_RESULT
     87 {
     88  return buf->changedtick_di.di_tv.vval.v_number;
     89 }
     90 
     91 static inline uint32_t buf_meta_total(const buf_T *b, MetaIndex m)
     92 {
     93  return b->b_marktree->meta_root[m];
     94 }