robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
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 { 17u_entry_T * ue_next ;///< pointer to next entry in list 18linenr_T ue_top ;///< number of line above undo block 19linenr_T ue_bot ;///< number of line below undo block 20linenr_T ue_lcount ;///< linecount when u_save called 21char ** ue_array ;///< array of lines in undo block 22linenr_T ue_size ;///< number of lines in ue_array 23#ifdef U_DEBUG 24int 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() 31union { 32u_header_T * ptr ;///< pointer to next undo header in list 33int seq ; 34 }uh_next ; 35union { 36u_header_T * ptr ;///< pointer to previous header in list 37int seq ; 38 }uh_prev ; 39union { 40u_header_T * ptr ;///< pointer to next header for alt. redo 41int seq ; 42 }uh_alt_next ; 43union { 44u_header_T * ptr ;///< pointer to previous header for alt. redo 45int seq ; 46 }uh_alt_prev ; 47int uh_seq ;///< sequence number, higher == newer undo 48int uh_walk ;///< used by undo_time() 49u_entry_T * uh_entry ;///< pointer to first entry 50u_entry_T * uh_getbot_entry ;///< pointer to where ue_bot must be set 51pos_T uh_cursor ;///< Pre-change cursor pos; restored on undo. 52pos_T uh_cursor_after ;///< Post-change pos; restored on redo. Not saved to undofile. 53colnr_T uh_cursor_vcol ;///< Virtual column of uh_cursor ('virtualedit'), or -1. 54int uh_flags ;///< see below 55fmark_T uh_namedm [NMARKS ];///< marks before undo/after redo 56extmark_undo_vec_t uh_extmark ;///< info to move extmarks 57visualinfo_T uh_visual ;///< Visual areas before undo/after redo 58time_t uh_time ;///< timestamp when the change was made 59int uh_save_nr ;///< set when the file was saved after the 60///< changes in this block 61#ifdef U_DEBUG 62int uh_magic ;///< magic number to check allocation 63#endif 64}; 65 66/// values for uh_flags 67enum { 68UH_CHANGED = 0x01 ,///< b_changed flag before undo/after redo 69UH_EMPTYBUF = 0x02 ,///< buffer was empty 70UH_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 { 77u_header_T * uc_oldhead ; 78u_header_T * uc_newhead ; 79u_header_T * uc_curhead ; 80int uc_numhead ; 81bool uc_synced ; 82int uc_seq_last ; 83int uc_save_nr_last ; 84int uc_seq_cur ; 85time_t uc_time_cur ; 86int uc_save_nr_cur ; 87char * uc_line_ptr ; 88linenr_T uc_line_lnum ; 89colnr_T uc_line_colnr ; 90OptInt uc_undolevels ;///< saved 'undolevels' 91varnumber_T uc_changedtick ;///< saved b:changedtick 92}UndoCheckpoint ;