Mercurial > vim
diff src/undo.c @ 17970:684a15da9929 v8.1.1981
patch 8.1.1981: the evalfunc.c file is too big
Commit: https://github.com/vim/vim/commit/08c308aeb5e7dfa18fa61f261b0bff79517a4883
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 4 17:48:15 2019 +0200
patch 8.1.1981: the evalfunc.c file is too big
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 04 Sep 2019 18:00:03 +0200 |
parents | 0f7ae8010787 |
children | d19caa851682 |
line wrap: on
line diff
--- 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_ 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