undo_defs.h (2722B)
1 #pragma once 2 3 #include <time.h> 4 5 #include "nvim/extmark_defs.h" 6 #include "nvim/mark_defs.h" 7 8 enum { UNDO_HASH_SIZE = 32, }; ///< Size in bytes of the hash used in the undo file. 9 10 typedef struct u_header u_header_T; 11 12 /// Structure to store info about the Visual area. 13 typedef struct { 14 pos_T vi_start; ///< start pos of last VIsual 15 pos_T vi_end; ///< end position of last VIsual 16 int vi_mode; ///< VIsual_mode of last VIsual 17 colnr_T vi_curswant; ///< MAXCOL from w_curswant 18 } visualinfo_T; 19 20 typedef struct u_entry u_entry_T; 21 struct u_entry { 22 u_entry_T *ue_next; ///< pointer to next entry in list 23 linenr_T ue_top; ///< number of line above undo block 24 linenr_T ue_bot; ///< number of line below undo block 25 linenr_T ue_lcount; ///< linecount when u_save called 26 char **ue_array; ///< array of lines in undo block 27 linenr_T ue_size; ///< number of lines in ue_array 28 #ifdef U_DEBUG 29 int ue_magic; ///< magic number to check allocation 30 #endif 31 }; 32 33 struct u_header { 34 // The following have a pointer and a number. The number is used when reading 35 // the undo file in u_read_undo() 36 union { 37 u_header_T *ptr; ///< pointer to next undo header in list 38 int seq; 39 } uh_next; 40 union { 41 u_header_T *ptr; ///< pointer to previous header in list 42 int seq; 43 } uh_prev; 44 union { 45 u_header_T *ptr; ///< pointer to next header for alt. redo 46 int seq; 47 } uh_alt_next; 48 union { 49 u_header_T *ptr; ///< pointer to previous header for alt. redo 50 int seq; 51 } uh_alt_prev; 52 int uh_seq; ///< sequence number, higher == newer undo 53 int uh_walk; ///< used by undo_time() 54 u_entry_T *uh_entry; ///< pointer to first entry 55 u_entry_T *uh_getbot_entry; ///< pointer to where ue_bot must be set 56 pos_T uh_cursor; ///< cursor position before saving 57 colnr_T uh_cursor_vcol; 58 int uh_flags; ///< see below 59 fmark_T uh_namedm[NMARKS]; ///< marks before undo/after redo 60 extmark_undo_vec_t uh_extmark; ///< info to move extmarks 61 visualinfo_T uh_visual; ///< Visual areas before undo/after redo 62 time_t uh_time; ///< timestamp when the change was made 63 int 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 enum { 72 UH_CHANGED = 0x01, ///< b_changed flag before undo/after redo 73 UH_EMPTYBUF = 0x02, ///< buffer was empty 74 UH_RELOAD = 0x04, ///< buffer was reloaded 75 };