diff src/ex_getln.c @ 18679:fd95d4dbeb37 v8.1.2331

patch 8.1.2331: the option.c file is still very big Commit: https://github.com/vim/vim/commit/7bae0b1bc84a95d565ffab38cf7f82ad21c656b6 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 21 22:14:18 2019 +0100 patch 8.1.2331: the option.c file is still very big Problem: The option.c file is still very big. Solution: Move a few functions to where they fit better. (Yegappan Lakshmanan, closes #4895)
author Bram Moolenaar <Bram@vim.org>
date Thu, 21 Nov 2019 22:15:03 +0100
parents 18d7337b6837
children d7c47e45bcc3
line wrap: on
line diff
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -52,6 +52,8 @@ static int	ccheck_abbr(int);
 
 #ifdef FEAT_CMDWIN
 static int	open_cmdwin(void);
+
+static int	cedit_key INIT(= -1);	// key value of 'cedit' option
 #endif
 
 
@@ -2460,6 +2462,60 @@ getcmdline_prompt(
 #endif
 
 /*
+ * Read the 'wildmode' option, fill wim_flags[].
+ */
+    int
+check_opt_wim(void)
+{
+    char_u	new_wim_flags[4];
+    char_u	*p;
+    int		i;
+    int		idx = 0;
+
+    for (i = 0; i < 4; ++i)
+	new_wim_flags[i] = 0;
+
+    for (p = p_wim; *p; ++p)
+    {
+	for (i = 0; ASCII_ISALPHA(p[i]); ++i)
+	    ;
+	if (p[i] != NUL && p[i] != ',' && p[i] != ':')
+	    return FAIL;
+	if (i == 7 && STRNCMP(p, "longest", 7) == 0)
+	    new_wim_flags[idx] |= WIM_LONGEST;
+	else if (i == 4 && STRNCMP(p, "full", 4) == 0)
+	    new_wim_flags[idx] |= WIM_FULL;
+	else if (i == 4 && STRNCMP(p, "list", 4) == 0)
+	    new_wim_flags[idx] |= WIM_LIST;
+	else if (i == 8 && STRNCMP(p, "lastused", 8) == 0)
+	    new_wim_flags[idx] |= WIM_BUFLASTUSED;
+	else
+	    return FAIL;
+	p += i;
+	if (*p == NUL)
+	    break;
+	if (*p == ',')
+	{
+	    if (idx == 3)
+		return FAIL;
+	    ++idx;
+	}
+    }
+
+    /* fill remaining entries with last flag */
+    while (idx < 3)
+    {
+	new_wim_flags[idx + 1] = new_wim_flags[idx];
+	++idx;
+    }
+
+    /* only when there are no errors, wim_flags[] is changed */
+    for (i = 0; i < 4; ++i)
+	wim_flags[i] = new_wim_flags[i];
+    return OK;
+}
+
+/*
  * Return TRUE when the text must not be changed and we can't switch to
  * another window or buffer.  Used when editing the command line, evaluating
  * 'balloonexpr', etc.
@@ -4028,6 +4084,27 @@ get_list_range(char_u **str, int *num1, 
 
 #if defined(FEAT_CMDWIN) || defined(PROTO)
 /*
+ * Check value of 'cedit' and set cedit_key.
+ * Returns NULL if value is OK, error message otherwise.
+ */
+    char *
+check_cedit(void)
+{
+    int n;
+
+    if (*p_cedit == NUL)
+	cedit_key = -1;
+    else
+    {
+	n = string_to_key(p_cedit, FALSE);
+	if (vim_isprintc(n))
+	    return e_invarg;
+	cedit_key = n;
+    }
+    return NULL;
+}
+
+/*
  * Open a window on the current command line and history.  Allow editing in
  * the window.  Returns when the window is closed.
  * Returns: