diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-05-22 20:35:17 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-05-22 20:35:17 +0200 |
commit | 0b6d911e5de1a1c10a23d4c2ee1b0275c474a2dd (patch) | |
tree | 3d33047a64f47e30852f5d6f187f316d12b3f55b /src/evalfunc.c | |
parent | b4518563c73460150344a57879bf5b22cb8b1c77 (diff) |
patch 8.1.0020: cannot tell whether a register is executing or recordingv8.1.0020
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.
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 46e55b3fd2..90aa2efd50 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -306,6 +306,8 @@ static void f_pyxeval(typval_T *argvars, typval_T *rettv); #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 *rettv) 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); |