#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <string.h>
#include "auto/config.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/buffer_updates.h"
#include "nvim/change.h"
#include "nvim/cursor.h"
#include "nvim/edit.h"
#include "nvim/extmark.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/lib/kvec.h"
#include "nvim/mark.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/pos.h"
#include "nvim/sha256.h"
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/types.h"
#include "nvim/undo.h"
Macros | |
#define | UH_MAGIC 0x18dade |
#define | UE_MAGIC 0xabc123 |
#define | UF_START_MAGIC "Vim\237UnDo\345" |
#define | UF_START_MAGIC_LEN 9 |
#define | UF_HEADER_MAGIC 0x5fd0 |
#define | UF_HEADER_END_MAGIC 0xe7aa |
#define | UF_ENTRY_MAGIC 0xf518 |
#define | UF_ENTRY_END_MAGIC 0x3581 |
#define | UF_VERSION 3 |
#define | UF_LAST_SAVE_NR 1 |
#define | UHP_SAVE_NR 1 |
#define | SET_FLAG(j) |
Variables | |
void char * | file_name |
int | mark = ++lastmark |
int | fd = os_open(file_name, O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm) |
FILE * | fp = NULL |
int | perm = 0600 |
bool | write_ok = false |
bufinfo_T | bi |
else | |
bi | bi_buf = buf |
bi | bi_fp = fp |
uhp = buf->b_u_oldhead | |
write_error | __pad0__ |
theend | __pad1__ |
#define SET_FLAG | ( | j | ) |
#define UE_MAGIC 0xabc123 |
#define UF_ENTRY_END_MAGIC 0x3581 |
#define UF_ENTRY_MAGIC 0xf518 |
#define UF_HEADER_END_MAGIC 0xe7aa |
#define UF_HEADER_MAGIC 0x5fd0 |
#define UF_LAST_SAVE_NR 1 |
#define UF_START_MAGIC "Vim\237UnDo\345" |
#define UF_START_MAGIC_LEN 9 |
#define UF_VERSION 3 |
#define UH_MAGIC 0x18dade |
#define UHP_SAVE_NR 1 |
Check if the 'modified' flag is set, or 'ff' has changed (only need to check the first character, because it can only be "dos", "unix" or "mac"). "nofile" and "scratch" type buffers are considered to always be unchanged.
buf | The buffer to check |
if | ( | !serialize_header &, | hash | ) |
if | ( | ! | write_ok | ) |
if | ( | ) |
if | ( | os_path_exists((char_u *) file_name) | ) |
if | ( | p_verbose | , |
0 | |||
) |
if | ( | undo_write_bytes(&, | uintmax_tUF_HEADER_END_MAGIC, |
2 | |||
) |
Compute the hash for a buffer text into hash[UNDO_HASH_SIZE].
[in] | buf | The buffer used to compute the hash |
[in] | hash | Array of size UNDO_HASH_SIZE in which to store the value of the hash |
list_T* u_eval_tree | ( | const u_header_T *const | first_uhp | ) |
Append the list of undo blocks to a newly allocated list
For use in undotree(). Recursive.
[in] | first_uhp | Undo blocks list to start with. |
u_header_T* u_force_get_undo_header | ( | buf_T * | buf | ) |
char* u_get_undo_file_name | ( | const char *const | buf_ffname, |
const bool | reading | ||
) |
Return an allocated string of the full path of the target undofile.
[in] | buf_ffname | Full file name for which undo file location should be found. |
[in] | reading | If true, find the file to read by traversing all of the directories in &undodir. If false use the first existing directory. If none of the directories in &undodir option exist then last directory in the list will be automatically created. |
int u_inssub | ( | linenr_T | lnum | ) |
Loads the undo tree from an undo file. If "name" is not NULL use it as the undo file name. This also means being a bit more verbose. Otherwise use curbuf->b_ffname to generate the undo file name. "hash[UNDO_HASH_SIZE]" must be the hash value of the buffer text.
void u_redo | ( | int | count | ) |
int u_save_cursor | ( | void | ) |
int u_savedel | ( | linenr_T | lnum, |
long | nlines | ||
) |
int u_savesub | ( | linenr_T | lnum | ) |
u_sync: stop adding to the current entry list
force | if true, also sync when no_u_sync is set. |
u_sync | ( | true | ) |
void u_undo | ( | int | count | ) |
bool u_undo_and_forget | ( | int | count | ) |
Undo and remove the branch from the undo tree. Also moves the cursor (as a "normal" undo would).
void u_write_undo | ( | const char *const | name, |
const bool | forceit, | ||
buf_T *const | buf, | ||
char_u *const | hash | ||
) |
Write the undo tree in an undo file.
[in] | name | Name of the undo file or NULL if this function needs to generate the undo file name based on buf->b_ffname. |
[in] | forceit | True for :wundo! , false otherwise. |
[in] | buf | Buffer for which undo file is written. |
[in] | hash | Hash value of the buffer text. Must have UNDO_HASH_SIZE size. |
Return true when undo is allowed. Otherwise print an error message and return false.
Put the timestamp of an undo header in "buf[buflen]" in a nice format.
write_error __pad0__ |
theend __pad1__ |
bufinfo_T bi |
fd = os_open(file_name, O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm) |
void char* file_name |
fp = NULL |
mark = ++lastmark |
perm = 0600 |
uhp = buf->b_u_oldhead |