Mercurial > vim
diff src/evalfunc.c @ 14004:e124262d435e v8.1.0020
patch 8.1.0020: cannot tell whether a register is executing or recording
commit https://github.com/vim/vim/commit/0b6d911e5de1a1c10a23d4c2ee1b0275c474a2dd
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 22 20:35:17 2018 +0200
patch 8.1.0020: cannot tell whether a register is executing or recording
Problem: Cannot tell whether a register is being used for executing or
recording.
Solution: Add reg_executing() and reg_recording(). (Hirohito Higashi,
closes #2745) Rename the global variables for consistency. Store
the register name in reg_executing.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 22 May 2018 20:45:05 +0200 |
parents | 4a41a169e5ea |
children | dc67449d648c |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -306,6 +306,8 @@ static void f_pyxeval(typval_T *argvars, #endif static void f_range(typval_T *argvars, typval_T *rettv); static void f_readfile(typval_T *argvars, typval_T *rettv); +static void f_reg_executing(typval_T *argvars, typval_T *rettv); +static void f_reg_recording(typval_T *argvars, typval_T *rettv); static void f_reltime(typval_T *argvars, typval_T *rettv); #ifdef FEAT_FLOAT static void f_reltimefloat(typval_T *argvars, typval_T *rettv); @@ -754,6 +756,8 @@ static struct fst #endif {"range", 1, 3, f_range}, {"readfile", 1, 3, f_readfile}, + {"reg_executing", 0, 0, f_reg_executing}, + {"reg_recording", 0, 0, f_reg_recording}, {"reltime", 0, 2, f_reltime}, #ifdef FEAT_FLOAT {"reltimefloat", 1, 1, f_reltimefloat}, @@ -8697,6 +8701,34 @@ f_readfile(typval_T *argvars, typval_T * fclose(fd); } + static void +return_register(int regname, typval_T *rettv) +{ + char_u buf[2] = {0, 0}; + + buf[0] = (char_u)regname; + rettv->v_type = VAR_STRING; + rettv->vval.v_string = vim_strsave(buf); +} + +/* + * "reg_executing()" function + */ + static void +f_reg_executing(typval_T *argvars UNUSED, typval_T *rettv) +{ + return_register(reg_executing, rettv); +} + +/* + * "reg_recording()" function + */ + static void +f_reg_recording(typval_T *argvars UNUSED, typval_T *rettv) +{ + return_register(reg_recording, rettv); +} + #if defined(FEAT_RELTIME) static int list2proftime(typval_T *arg, proftime_T *tm);