summaryrefslogtreecommitdiff
path: root/src/ex_getln.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-04 17:48:15 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-04 17:48:15 +0200
commit08c308aeb5e7dfa18fa61f261b0bff79517a4883 (patch)
tree0262ab37d02fa41b05667b94992e51b232a8c1ef /src/ex_getln.c
parent0f63ed33fdd12d8220f7bc7ff91095e7ceed9985 (diff)
downloadvim-git-08c308aeb5e7dfa18fa61f261b0bff79517a4883.tar.gz
patch 8.1.1981: the evalfunc.c file is too bigv8.1.1981
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.
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r--src/ex_getln.c57
1 files changed, 46 insertions, 11 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 857c9c74f..ce32dbe33 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -3868,7 +3868,7 @@ get_ccline_ptr(void)
* Only works when the command line is being edited.
* Returns NULL when something is wrong.
*/
- char_u *
+ static char_u *
get_cmdline_str(void)
{
cmdline_info_T *p;
@@ -3882,19 +3882,26 @@ get_cmdline_str(void)
}
/*
- * Get the current command line position, counted in bytes.
- * Zero is the first position.
- * Only works when the command line is being edited.
- * Returns -1 when something is wrong.
+ * "getcmdline()" function
*/
- int
-get_cmdline_pos(void)
+ void
+f_getcmdline(typval_T *argvars UNUSED, typval_T *rettv)
+{
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = get_cmdline_str();
+}
+
+/*
+ * "getcmdpos()" function
+ */
+ void
+f_getcmdpos(typval_T *argvars UNUSED, typval_T *rettv)
{
cmdline_info_T *p = get_ccline_ptr();
- if (p == NULL)
- return -1;
- return p->cmdpos;
+ rettv->vval.v_number = 0;
+ if (p != NULL)
+ rettv->vval.v_number = p->cmdpos + 1;
}
/*
@@ -3902,7 +3909,7 @@ get_cmdline_pos(void)
* Only works when the command line is being edited.
* Returns 1 when failed, 0 when OK.
*/
- int
+ static int
set_cmdline_pos(
int pos)
{
@@ -3919,6 +3926,34 @@ set_cmdline_pos(
new_cmdpos = pos;
return 0;
}
+
+/*
+ * "setcmdpos()" function
+ */
+ void
+f_setcmdpos(typval_T *argvars, typval_T *rettv)
+{
+ int pos = (int)tv_get_number(&argvars[0]) - 1;
+
+ if (pos >= 0)
+ rettv->vval.v_number = set_cmdline_pos(pos);
+}
+
+/*
+ * "getcmdtype()" function
+ */
+ void
+f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv)
+{
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = alloc(2);
+ if (rettv->vval.v_string != NULL)
+ {
+ rettv->vval.v_string[0] = get_cmdline_type();
+ rettv->vval.v_string[1] = NUL;
+ }
+}
+
#endif
#if defined(FEAT_EVAL) || defined(FEAT_CMDWIN) || defined(PROTO)