robin/laufey

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

robinmerge: 1dc9728daa1d8a2702

master
3.3 KiB92 linesraw
1#pragma once
2
3#include <time.h>
4
5#include "nvim/eval/typval_defs.h"
6#include "nvim/extmark_defs.h"
7#include "nvim/mark_defs.h"
8#include "nvim/normal_defs.h"
9#include "nvim/option_defs.h"
10
11enum { UNDO_HASH_SIZE = 32, };  ///< Size in bytes of the hash used in the undo file.
12
13typedef struct u_header u_header_T;
14
15typedef struct u_entry u_entry_T;
16struct u_entry {
17  u_entry_T *ue_next;  ///< pointer to next entry in list
18  linenr_T ue_top;     ///< number of line above undo block
19  linenr_T ue_bot;     ///< number of line below undo block
20  linenr_T ue_lcount;  ///< linecount when u_save called
21  char **ue_array;     ///< array of lines in undo block
22  linenr_T ue_size;    ///< number of lines in ue_array
23#ifdef U_DEBUG
24  int ue_magic;        ///< magic number to check allocation
25#endif
26};
27
28struct u_header {
29  // The following have a pointer and a number. The number is used when reading
30  // the undo file in u_read_undo()
31  union {
32    u_header_T *ptr;              ///< pointer to next undo header in list
33    int seq;
34  } uh_next;
35  union {
36    u_header_T *ptr;              ///< pointer to previous header in list
37    int seq;
38  } uh_prev;
39  union {
40    u_header_T *ptr;              ///< pointer to next header for alt. redo
41    int seq;
42  } uh_alt_next;
43  union {
44    u_header_T *ptr;              ///< pointer to previous header for alt. redo
45    int seq;
46  } uh_alt_prev;
47  int uh_seq;                     ///< sequence number, higher == newer undo
48  int uh_walk;                    ///< used by undo_time()
49  u_entry_T *uh_entry;            ///< pointer to first entry
50  u_entry_T *uh_getbot_entry;     ///< pointer to where ue_bot must be set
51  pos_T uh_cursor;                ///< Pre-change cursor pos; restored on undo.
52  pos_T uh_cursor_after;          ///< Post-change pos; restored on redo. Not saved to undofile.
53  colnr_T uh_cursor_vcol;         ///< Virtual column of uh_cursor ('virtualedit'), or -1.
54  int uh_flags;                   ///< see below
55  fmark_T uh_namedm[NMARKS];      ///< marks before undo/after redo
56  extmark_undo_vec_t uh_extmark;  ///< info to move extmarks
57  visualinfo_T uh_visual;         ///< Visual areas before undo/after redo
58  time_t uh_time;                 ///< timestamp when the change was made
59  int uh_save_nr;                 ///< set when the file was saved after the
60                                  ///< changes in this block
61#ifdef U_DEBUG
62  int uh_magic;                   ///< magic number to check allocation
63#endif
64};
65
66/// values for uh_flags
67enum {
68  UH_CHANGED  = 0x01,  ///< b_changed flag before undo/after redo
69  UH_EMPTYBUF = 0x02,  ///< buffer was empty
70  UH_RELOAD   = 0x04,  ///< buffer was reloaded
71};
72
73/// Checkpoint of buffer undo state, for "undo-invisible" speculative edits: u_checkpoint() detaches
74/// the undo tree so subsequent edits build a disposable one; u_rollback() reverts those edits and
75/// reattaches the checkpointed tree.  Used by 'inccommand' preview.
76typedef struct {
77  u_header_T *uc_oldhead;
78  u_header_T *uc_newhead;
79  u_header_T *uc_curhead;
80  int uc_numhead;
81  bool uc_synced;
82  int uc_seq_last;
83  int uc_save_nr_last;
84  int uc_seq_cur;
85  time_t uc_time_cur;
86  int uc_save_nr_cur;
87  char *uc_line_ptr;
88  linenr_T uc_line_lnum;
89  colnr_T uc_line_colnr;
90  OptInt uc_undolevels;        ///< saved 'undolevels'
91  varnumber_T uc_changedtick;  ///< saved b:changedtick
92} UndoCheckpoint;