1#ifndef NVIM_UNDO_DEFS_H
2#define NVIM_UNDO_DEFS_H
3
4#include <time.h> // for time_t
5
6#include "nvim/pos.h"
7#include "nvim/mark_defs.h"
8
9typedef struct u_header u_header_T;
10
11/* Structure to store info about the Visual area. */
12typedef struct {
13 pos_T vi_start; /* start pos of last VIsual */
14 pos_T vi_end; /* end position of last VIsual */
15 int vi_mode; /* VIsual_mode of last VIsual */
16 colnr_T vi_curswant; /* MAXCOL from w_curswant */
17} visualinfo_T;
18
19#include "nvim/buffer_defs.h"
20
21typedef struct u_entry u_entry_T;
22struct u_entry {
23 u_entry_T *ue_next; /* pointer to next entry in list */
24 linenr_T ue_top; /* number of line above undo block */
25 linenr_T ue_bot; /* number of line below undo block */
26 linenr_T ue_lcount; /* linecount when u_save called */
27 char_u **ue_array; /* array of lines in undo block */
28 long ue_size; /* number of lines in ue_array */
29#ifdef U_DEBUG
30 int ue_magic; /* magic number to check allocation */
31#endif
32};
33
34struct u_header {
35 /* The following have a pointer and a number. The number is used when
36 * reading the undo file in u_read_undo() */
37 union {
38 u_header_T *ptr; /* pointer to next undo header in list */
39 long seq;
40 } uh_next;
41 union {
42 u_header_T *ptr; /* pointer to previous header in list */
43 long seq;
44 } uh_prev;
45 union {
46 u_header_T *ptr; /* pointer to next header for alt. redo */
47 long seq;
48 } uh_alt_next;
49 union {
50 u_header_T *ptr; /* pointer to previous header for alt. redo */
51 long seq;
52 } uh_alt_prev;
53 long uh_seq; /* sequence number, higher == newer undo */
54 int uh_walk; /* used by undo_time() */
55 u_entry_T *uh_entry; /* pointer to first entry */
56 u_entry_T *uh_getbot_entry; /* pointer to where ue_bot must be set */
57 pos_T uh_cursor; /* cursor position before saving */
58 long uh_cursor_vcol;
59 int uh_flags; /* see below */
60 fmark_T uh_namedm[NMARKS]; /* marks before undo/after redo */
61 visualinfo_T uh_visual; /* Visual areas before undo/after redo */
62 time_t uh_time; /* timestamp when the change was made */
63 long uh_save_nr; /* set when the file was saved after the
64 changes in this block */
65#ifdef U_DEBUG
66 int uh_magic; /* magic number to check allocation */
67#endif
68};
69
70/* values for uh_flags */
71#define UH_CHANGED 0x01 /* b_changed flag before undo/after redo */
72#define UH_EMPTYBUF 0x02 /* buffer was empty */
73
74/// Structure passed around between undofile functions.
75typedef struct {
76 buf_T *bi_buf;
77 FILE *bi_fp;
78} bufinfo_T;
79
80#endif // NVIM_UNDO_DEFS_H
81