aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c80
1 files changed, 79 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index c7d4e32739..3fb19ad153 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -10404,6 +10404,26 @@ static void f_gettabwinvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
getwinvar(argvars, rettv, 1);
}
+/*
+ * "gettagstack()" function
+ */
+ static void
+f_gettagstack(typval_T *argvars, typval_T *rettv, FunPtr fptr)
+{
+ win_T *wp = curwin; // default is current window
+
+ tv_dict_alloc_ret(rettv);
+
+ if (argvars[0].v_type != VAR_UNKNOWN)
+ {
+ wp = find_win_by_nr_or_id(&argvars[0]);
+ if (wp == NULL)
+ return;
+ }
+
+ get_tagstack(wp, rettv->vval.v_dict);
+}
+
/// Returns information about a window as a dictionary.
static dict_T *get_win_info(win_T *wp, int16_t tpnr, int16_t winnr)
{
@@ -15197,6 +15217,64 @@ static void f_settabwinvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
/*
+ * "settagstack()" function
+ */
+ static void
+f_settagstack(typval_T *argvars, typval_T *rettv, FunPtr fptr)
+{
+ static char *e_invact2 = N_("E962: Invalid action: '%s'");
+ win_T *wp;
+ dict_T *d;
+ int action = 'r';
+
+ rettv->vval.v_number = -1;
+
+ // first argument: window number or id
+ wp = find_win_by_nr_or_id(&argvars[0]);
+ if (wp == NULL)
+ return;
+
+ // second argument: dict with items to set in the tag stack
+ if (argvars[1].v_type != VAR_DICT)
+ {
+ EMSG(_(e_dictreq));
+ return;
+ }
+ d = argvars[1].vval.v_dict;
+ if (d == NULL)
+ return;
+
+ // third argument: action - 'a' for append and 'r' for replace.
+ // default is to replace the stack.
+ if (argvars[2].v_type == VAR_UNKNOWN)
+ action = 'r';
+ else if (argvars[2].v_type == VAR_STRING)
+ {
+ const char *actstr;
+ actstr = tv_get_string_chk(&argvars[2]);
+ if (actstr == NULL)
+ return;
+ if ((*actstr == 'r' || *actstr == 'a') && actstr[1] == NUL)
+ action = *actstr;
+ else
+ {
+ EMSG2(_(e_invact2), actstr);
+ return;
+ }
+ }
+ else
+ {
+ EMSG(_(e_stringreq));
+ return;
+ }
+
+ if (set_tagstack(wp, d, action) == OK)
+ rettv->vval.v_number = 0;
+ else
+ EMSG(_(e_listreq));
+}
+
+/*
* "setwinvar()" function
*/
static void f_setwinvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
@@ -18197,7 +18275,7 @@ pos_T *var2fpos(const typval_T *const tv, const int dollar_lnum,
* Return FAIL when conversion is not possible, doesn't check the position for
* validity.
*/
-static int list2fpos(typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp)
+int list2fpos(typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp)
{
list_T *l;
long i = 0;