aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorJames McCoy <vega.james@gmail.com>2015-08-19 21:53:52 -0400
committerJames McCoy <vega.james@gmail.com>2015-08-20 10:32:25 -0400
commitf6f28c18e5824b13f4a20a481a9f350f0e652e9b (patch)
tree32a5dd8a94ae9891d9e3d3f65abdb14f75c8f108 /src/nvim/eval.c
parent08bae4533704120199c188eb3cfac2b6ba4096c0 (diff)
downloadrneovim-f6f28c18e5824b13f4a20a481a9f350f0e652e9b.tar.gz
rneovim-f6f28c18e5824b13f4a20a481a9f350f0e652e9b.tar.bz2
rneovim-f6f28c18e5824b13f4a20a481a9f350f0e652e9b.zip
7.4.813
patch 7.4.813 Problem: It is not possible to save and restore character search state. Solution: Add getcharsearch() and setcharsearch(). (James McCoy) https://github.com/vim/vim/releases/tag/v7.4.813 https://github.com/vim/vim/releases/tag/v7.4.826 Signed-off-by: James McCoy <vega.james@gmail.com>
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index bf9a219e28..a5ab57785c 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -6599,6 +6599,7 @@ static struct fst {
{"getbufvar", 2, 3, f_getbufvar},
{"getchar", 0, 1, f_getchar},
{"getcharmod", 0, 0, f_getcharmod},
+ {"getcharsearch", 0, 0, f_getcharsearch},
{"getcmdline", 0, 0, f_getcmdline},
{"getcmdpos", 0, 0, f_getcmdpos},
{"getcmdtype", 0, 0, f_getcmdtype},
@@ -6725,6 +6726,7 @@ static struct fst {
{"serverstart", 0, 1, f_serverstart},
{"serverstop", 1, 1, f_serverstop},
{"setbufvar", 3, 3, f_setbufvar},
+ {"setcharsearch", 1, 1, f_setcharsearch},
{"setcmdpos", 1, 1, f_setcmdpos},
{"setline", 2, 2, f_setline},
{"setloclist", 2, 3, f_setloclist},
@@ -9304,6 +9306,20 @@ static void f_getcharmod(typval_T *argvars, typval_T *rettv)
}
/*
+ * "getcharsearch()" function
+ */
+static void f_getcharsearch(typval_T *argvars, typval_T *rettv)
+{
+ rettv_dict_alloc(rettv);
+
+ dict_T *dict = rettv->vval.v_dict;
+
+ dict_add_nr_str(dict, "char", 0L, last_csearch());
+ dict_add_nr_str(dict, "forward", last_csearch_forward(), NULL);
+ dict_add_nr_str(dict, "until", last_csearch_until(), NULL);
+}
+
+/*
* "getcmdline()" function
*/
static void f_getcmdline(typval_T *argvars, typval_T *rettv)
@@ -14299,6 +14315,40 @@ static void f_setbufvar(typval_T *argvars, typval_T *rettv)
}
}
+static void f_setcharsearch(typval_T *argvars, typval_T *rettv)
+{
+ dict_T *d;
+ dictitem_T *di;
+ char_u *csearch;
+
+ if (argvars[0].v_type != VAR_DICT) {
+ EMSG(_(e_dictreq));
+ return;
+ }
+
+ if ((d = argvars[0].vval.v_dict) != NULL) {
+ csearch = get_dict_string(d, (char_u *)"char", FALSE);
+ if (csearch != NULL) {
+ if (enc_utf8) {
+ int pcc[MAX_MCO];
+ int c = utfc_ptr2char(csearch, pcc);
+ set_last_csearch(c, csearch, utfc_ptr2len(csearch));
+ }
+ else
+ set_last_csearch(PTR2CHAR(csearch),
+ csearch, MB_PTR2LEN(csearch));
+ }
+
+ di = dict_find(d, (char_u *)"forward", -1);
+ if (di != NULL)
+ set_csearch_direction(get_tv_number(&di->di_tv) ? FORWARD : BACKWARD);
+
+ di = dict_find(d, (char_u *)"until", -1);
+ if (di != NULL)
+ set_csearch_until(!!get_tv_number(&di->di_tv));
+ }
+}
+
/*
* "setcmdpos()" function
*/