diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-04 17:48:15 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-04 17:48:15 +0200 |
commit | 08c308aeb5e7dfa18fa61f261b0bff79517a4883 (patch) | |
tree | 0262ab37d02fa41b05667b94992e51b232a8c1ef /src/undo.c | |
parent | 0f63ed33fdd12d8220f7bc7ff91095e7ceed9985 (diff) | |
download | vim-git-08c308aeb5e7dfa18fa61f261b0bff79517a4883.tar.gz |
patch 8.1.1981: the evalfunc.c file is too bigv8.1.1981
Problem: The evalfunc.c file is too big.
Solution: Move undo functions to undo.c. Move cmdline functions to
ex_getln.c. Move some container functions to list.c.
Diffstat (limited to 'src/undo.c')
-rw-r--r-- | src/undo.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/undo.c b/src/undo.c index b9c203ce2..e6bce43c2 100644 --- a/src/undo.c +++ b/src/undo.c @@ -3572,6 +3572,7 @@ curbufIsChanged(void) } #if defined(FEAT_EVAL) || defined(PROTO) + /* * For undotree(): Append the list of undo blocks at "first_uhp" to "list". * Recursive. @@ -3612,4 +3613,62 @@ u_eval_tree(u_header_T *first_uhp, list_T *list) uhp = uhp->uh_prev.ptr; } } + +/* + * "undofile(name)" function + */ + void +f_undofile(typval_T *argvars UNUSED, typval_T *rettv) +{ + rettv->v_type = VAR_STRING; +#ifdef FEAT_PERSISTENT_UNDO + { + char_u *fname = tv_get_string(&argvars[0]); + + if (*fname == NUL) + { + /* If there is no file name there will be no undo file. */ + rettv->vval.v_string = NULL; + } + else + { + char_u *ffname = FullName_save(fname, TRUE); + + if (ffname != NULL) + rettv->vval.v_string = u_get_undo_file_name(ffname, FALSE); + vim_free(ffname); + } + } +#else + rettv->vval.v_string = NULL; +#endif +} + +/* + * "undotree()" function + */ + void +f_undotree(typval_T *argvars UNUSED, typval_T *rettv) +{ + if (rettv_dict_alloc(rettv) == OK) + { + dict_T *dict = rettv->vval.v_dict; + list_T *list; + + dict_add_number(dict, "synced", (long)curbuf->b_u_synced); + dict_add_number(dict, "seq_last", curbuf->b_u_seq_last); + dict_add_number(dict, "save_last", (long)curbuf->b_u_save_nr_last); + dict_add_number(dict, "seq_cur", curbuf->b_u_seq_cur); + dict_add_number(dict, "time_cur", (long)curbuf->b_u_time_cur); + dict_add_number(dict, "save_cur", (long)curbuf->b_u_save_nr_cur); + + list = list_alloc(); + if (list != NULL) + { + u_eval_tree(curbuf->b_u_oldhead, list); + dict_add_list(dict, "entries", list); + } + } +} + #endif |