summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-11-21 22:14:18 +0100
committerBram Moolenaar <Bram@vim.org>2019-11-21 22:14:18 +0100
commit7bae0b1bc84a95d565ffab38cf7f82ad21c656b6 (patch)
tree2d724ddd855892ef212f14924e2cc04feafa5abe
parent94d9f4fa65bce6f116cf89bfdabdf5a06509056f (diff)
patch 8.1.2331: the option.c file is still very bigv8.1.2331
Problem: The option.c file is still very big. Solution: Move a few functions to where they fit better. (Yegappan Lakshmanan, closes #4895)
-rw-r--r--src/change.c51
-rw-r--r--src/ex_getln.c77
-rw-r--r--src/globals.h1
-rw-r--r--src/gui.c23
-rw-r--r--src/indent.c44
-rw-r--r--src/option.c423
-rw-r--r--src/proto/change.pro2
-rw-r--r--src/proto/ex_getln.pro2
-rw-r--r--src/proto/gui.pro2
-rw-r--r--src/proto/indent.pro1
-rw-r--r--src/proto/option.pro8
-rw-r--r--src/proto/term.pro1
-rw-r--r--src/proto/ui.pro2
-rw-r--r--src/term.c34
-rw-r--r--src/ui.c93
-rw-r--r--src/version.c2
16 files changed, 332 insertions, 434 deletions
diff --git a/src/change.c b/src/change.c
index e274d5d98f..b4349c6750 100644
--- a/src/change.c
+++ b/src/change.c
@@ -868,6 +868,57 @@ unchanged(buf_T *buf, int ff, int always_inc_changedtick)
}
/*
+ * Save the current values of 'fileformat' and 'fileencoding', so that we know
+ * the file must be considered changed when the value is different.
+ */
+ void
+save_file_ff(buf_T *buf)
+{
+ buf->b_start_ffc = *buf->b_p_ff;
+ buf->b_start_eol = buf->b_p_eol;
+ buf->b_start_bomb = buf->b_p_bomb;
+
+ /* Only use free/alloc when necessary, they take time. */
+ if (buf->b_start_fenc == NULL
+ || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
+ {
+ vim_free(buf->b_start_fenc);
+ buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
+ }
+}
+
+/*
+ * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
+ * from when editing started (save_file_ff() called).
+ * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
+ * changed and 'binary' is not set.
+ * Also when 'endofline' was changed and 'fixeol' is not set.
+ * When "ignore_empty" is true don't consider a new, empty buffer to be
+ * changed.
+ */
+ int
+file_ff_differs(buf_T *buf, int ignore_empty)
+{
+ /* In a buffer that was never loaded the options are not valid. */
+ if (buf->b_flags & BF_NEVERLOADED)
+ return FALSE;
+ if (ignore_empty
+ && (buf->b_flags & BF_NEW)
+ && buf->b_ml.ml_line_count == 1
+ && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
+ return FALSE;
+ if (buf->b_start_ffc != *buf->b_p_ff)
+ return TRUE;
+ if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
+ return TRUE;
+ if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
+ return TRUE;
+ if (buf->b_start_fenc == NULL)
+ return (*buf->b_p_fenc != NUL);
+ return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
+}
+
+/*
* Insert string "p" at the cursor position. Stops at a NUL byte.
* Handles Replace mode and multi-byte characters.
*/
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 5cc1c34897..7d2efcac42 100644
--- 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, int *num2)
#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:
diff --git a/src/globals.h b/src/globals.h
index fd1e6933c5..84fe28bef1 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1249,7 +1249,6 @@ EXTERN int km_stopsel INIT(= FALSE);
EXTERN int km_startsel INIT(= FALSE);
#ifdef FEAT_CMDWIN
-EXTERN int cedit_key INIT(= -1); // key value of 'cedit' option
EXTERN int cmdwin_type INIT(= 0); // type of cmdline window or 0
EXTERN int cmdwin_result INIT(= 0); // result of cmdline window or 0
#endif
diff --git a/src/gui.c b/src/gui.c
index 275f3fe066..5f86cc9294 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -4742,6 +4742,29 @@ gui_get_lightness(guicolor_T pixel)
+ ((rgb & 0xff) * 114)) / 1000;
}
+ char_u *
+gui_bg_default(void)
+{
+ if (gui_get_lightness(gui.back_pixel) < 127)
+ return (char_u *)"dark";
+ return (char_u *)"light";
+}
+
+/*
+ * Option initializations that can only be done after opening the GUI window.
+ */
+ void
+init_gui_options(void)
+{
+ /* Set the 'background' option according to the lightness of the
+ * background color, unless the user has set it already. */
+ if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
+ {
+ set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
+ highlight_changed();
+ }
+}
+
#if defined(FEAT_GUI_X11) || defined(PROTO)
void
gui_new_scrollbar_colors(void)
diff --git a/src/indent.c b/src/indent.c
index 8d574c8a71..70bb81b0db 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -839,6 +839,50 @@ get_number_indent(linenr_T lnum)
#if defined(FEAT_LINEBREAK) || defined(PROTO)
/*
+ * This is called when 'breakindentopt' is changed and when a window is
+ * initialized.
+ */
+ int
+briopt_check(win_T *wp)
+{
+ char_u *p;
+ int bri_shift = 0;
+ long bri_min = 20;
+ int bri_sbr = FALSE;
+
+ p = wp->w_p_briopt;
+ while (*p != NUL)
+ {
+ if (STRNCMP(p, "shift:", 6) == 0
+ && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
+ {
+ p += 6;
+ bri_shift = getdigits(&p);
+ }
+ else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
+ {
+ p += 4;
+ bri_min = getdigits(&p);
+ }
+ else if (STRNCMP(p, "sbr", 3) == 0)
+ {
+ p += 3;
+ bri_sbr = TRUE;
+ }
+ if (*p != ',' && *p != NUL)
+ return FAIL;
+ if (*p == ',')
+ ++p;
+ }
+
+ wp->w_p_brishift = bri_shift;
+ wp->w_p_brimin = bri_min;
+ wp->w_p_brisbr = bri_sbr;
+
+ return OK;
+}
+
+/*
* Return appropriate space number for breakindent, taking influencing
* parameters into account. Window must be specified, since it is not
* necessarily always the current one.
diff --git a/src/option.c b/src/option.c
index c54fc82681..1ccb5d9ec1 100644
--- a/src/option.c
+++ b/src/option.c
@@ -37,7 +37,6 @@
static void set_options_default(int opt_flags);
static void set_string_default_esc(char *name, char_u *val, int escape);
-static char_u *term_bg_default(void);
static char_u *option_expand(int opt_idx, char_u *val);
static void didset_options(void);
static void didset_options2(void);
@@ -800,40 +799,6 @@ set_init_2(void)
}
/*
- * Return "dark" or "light" depending on the kind of terminal.
- * This is just guessing! Recognized are:
- * "linux" Linux console
- * "screen.linux" Linux console with screen
- * "cygwin.*" Cygwin shell
- * "putty.*" Putty program
- * We also check the COLORFGBG environment variable, which is set by
- * rxvt and derivatives. This variable contains either two or three
- * values separated by semicolons; we want the last value in either
- * case. If this value is 0-6 or 8, our background is dark.
- */
- static char_u *
-term_bg_default(void)
-{
-#if defined(MSWIN)
- /* DOS console is nearly always black */
- return (char_u *)"dark";
-#else
- char_u *p;
-
- if (STRCMP(T_NAME, "linux") == 0
- || STRCMP(T_NAME, "screen.linux") == 0
- || STRNCMP(T_NAME, "cygwin", 6) == 0
- || STRNCMP(T_NAME, "putty", 5) == 0
- || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
- && (p = vim_strrchr(p, ';')) != NULL
- && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
- && p[2] == NUL))
- return (char_u *)"dark";
- return (char_u *)"light";
-#endif
-}
-
-/*
* Initialize the options, part three: After reading the .vimrc
*/
void
@@ -1057,31 +1022,6 @@ set_helplang_default(char_u *lang)
}
#endif
-#ifdef FEAT_GUI
- static char_u *
-gui_bg_default(void)
-{
- if (gui_get_lightness(gui.back_pixel) < 127)
- return (char_u *)"dark";
- return (char_u *)"light";
-}
-
-/*
- * Option initializations that can only be done after opening the GUI window.
- */
- void
-init_gui_options(void)
-{
- /* Set the 'background' option according to the lightness of the
- * background color, unless the user has set it already. */
- if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
- {
- set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
- highlight_changed();
- }
-}
-#endif
-
#ifdef FEAT_TITLE
/*
* 'title' and 'icon' only default to true if they have not been set or reset
@@ -2177,29 +2117,6 @@ string_to_key(char_u *arg, int multi_byte)
return *arg;
}
-#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;
-}
-#endif
-
#ifdef FEAT_TITLE
/*
* When changing 'title', 'titlestring', 'icon' or 'iconstring', call
@@ -2508,99 +2425,6 @@ valid_name(char_u *val, char *allowed)
return TRUE;
}
-#if defined(FEAT_CLIPBOARD) || defined(PROTO)
-/*
- * Extract the items in the 'clipboard' option and set global values.
- * Return an error message or NULL for success.
- */
- char *
-check_clipboard_option(void)
-{
- int new_unnamed = 0;
- int new_autoselect_star = FALSE;
- int new_autoselect_plus = FALSE;
- int new_autoselectml = FALSE;
- int new_html = FALSE;
- regprog_T *new_exclude_prog = NULL;
- char *errmsg = NULL;
- char_u *p;
-
- for (p = p_cb; *p != NUL; )
- {
- if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
- {
- new_unnamed |= CLIP_UNNAMED;
- p += 7;
- }
- else if (STRNCMP(p, "unnamedplus", 11) == 0
- && (p[11] == ',' || p[11] == NUL))
- {
- new_unnamed |= CLIP_UNNAMED_PLUS;
- p += 11;
- }
- else if (STRNCMP(p, "autoselect", 10) == 0
- && (p[10] == ',' || p[10] == NUL))
- {
- new_autoselect_star = TRUE;
- p += 10;
- }
- else if (STRNCMP(p, "autoselectplus", 14) == 0
- && (p[14] == ',' || p[14] == NUL))
- {
- new_autoselect_plus = TRUE;
- p += 14;
- }
- else if (STRNCMP(p, "autoselectml", 12) == 0
- && (p[12] == ',' || p[12] == NUL))
- {
- new_autoselectml = TRUE;
- p += 12;
- }
- else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
- {
- new_html = TRUE;
- p += 4;
- }
- else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
- {
- p += 8;
- new_exclude_prog = vim_regcomp(p, RE_MAGIC);
- if (new_exclude_prog == NULL)
- errmsg = e_invarg;
- break;
- }
- else
- {
- errmsg = e_invarg;
- break;
- }
- if (*p == ',')
- ++p;
- }
- if (errmsg == NULL)
- {
- clip_unnamed = new_unnamed;
- clip_autoselect_star = new_autoselect_star;
- clip_autoselect_plus = new_autoselect_plus;
- clip_autoselectml = new_autoselectml;
- clip_html = new_html;
- vim_regfree(clip_exclude_prog);
- clip_exclude_prog = new_exclude_prog;
-#ifdef FEAT_GUI_GTK
- if (gui.in_use)
- {
- gui_gtk_set_selection_targets();
- gui_gtk_set_dnd_targets();
- }
-#endif
- }
- else
- vim_regfree(new_exclude_prog);
-
- return errmsg;
-}
-#endif
-
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Set the script_ctx for an option, taking care of setting the buffer- or
@@ -6983,60 +6807,6 @@ fill_breakat_flags(void)
#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;
-}
-
-/*
* Check if backspacing over something is allowed.
*/
int
@@ -7057,57 +6827,6 @@ can_bs(
}
/*
- * Save the current values of 'fileformat' and 'fileencoding', so that we know
- * the file must be considered changed when the value is different.
- */
- void
-save_file_ff(buf_T *buf)
-{
- buf->b_start_ffc = *buf->b_p_ff;
- buf->b_start_eol = buf->b_p_eol;
- buf->b_start_bomb = buf->b_p_bomb;
-
- /* Only use free/alloc when necessary, they take time. */
- if (buf->b_start_fenc == NULL
- || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
- {
- vim_free(buf->b_start_fenc);
- buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
- }
-}
-
-/*
- * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
- * from when editing started (save_file_ff() called).
- * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
- * changed and 'binary' is not set.
- * Also when 'endofline' was changed and 'fixeol' is not set.
- * When "ignore_empty" is true don't consider a new, empty buffer to be
- * changed.
- */
- int
-file_ff_differs(buf_T *buf, int ignore_empty)
-{
- /* In a buffer that was never loaded the options are not valid. */
- if (buf->b_flags & BF_NEVERLOADED)
- return FALSE;
- if (ignore_empty
- && (buf->b_flags & BF_NEW)
- && buf->b_ml.ml_line_count == 1
- && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
- return FALSE;
- if (buf->b_start_ffc != *buf->b_p_ff)
- return TRUE;
- if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
- return TRUE;
- if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
- return TRUE;
- if (buf->b_start_fenc == NULL)
- return (*buf->b_p_fenc != NUL);
- return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
-}
-
-/*
* Return the effective 'scrolloff' value for the current window, using the
* global value when appropriate.
*/
@@ -7128,148 +6847,6 @@ get_sidescrolloff_value(void)
}
/*
- * Check matchpairs option for "*initc".
- * If there is a match set "*initc" to the matching character and "*findc" to
- * the opposite character. Set "*backwards" to the direction.
- * When "switchit" is TRUE swap the direction.
- */
- void
-find_mps_values(
- int *initc,
- int *findc,
- int *backwards,
- int switchit)
-{
- char_u *ptr;
-
- ptr = curbuf->b_p_mps;
- while (*ptr != NUL)
- {
- if (has_mbyte)
- {
- char_u *prev;
-
- if (mb_ptr2char(ptr) == *initc)
- {
- if (switchit)
- {
- *findc = *initc;
- *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
- *backwards = TRUE;
- }
- else
- {
- *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
- *backwards = FALSE;
- }
- return;
- }
- prev = ptr;
- ptr += mb_ptr2len(ptr) + 1;
- if (mb_ptr2char(ptr) == *initc)
- {
- if (switchit)
- {
- *findc = *initc;
- *initc = mb_ptr2char(prev);
- *backwards = FALSE;
- }
- else
- {
- *findc = mb_ptr2char(prev);
- *backwards = TRUE;
- }
- return;
- }
- ptr += mb_ptr2len(ptr);
- }
- else
- {
- if (*ptr == *initc)
- {
- if (switchit)
- {
- *backwards = TRUE;
- *findc = *initc;
- *initc = ptr[2];
- }
- else
- {
- *backwards = FALSE;
- *findc = ptr[2];
- }
- return;
- }
- ptr += 2;
- if (*ptr == *initc)
- {
- if (switchit)
- {
- *backwards = FALSE;
- *findc = *initc;
- *initc = ptr[-2];
- }
- else
- {
- *backwards = TRUE;
- *findc = ptr[-2];
- }
- return;
- }
- ++ptr;
- }
- if (*ptr == ',')
- ++ptr;
- }
-}
-
-#if defined(FEAT_LINEBREAK) || defined(PROTO)
-/*
- * This is called when 'breakindentopt' is changed and when a window is
- * initialized.
- */
- int
-briopt_check(win_T *wp)
-{
- char_u *p;
- int bri_shift = 0;
- long bri_min = 20;
- int bri_sbr = FALSE;
-
- p = wp->w_p_briopt;
- while (*p != NUL)
- {
- if (STRNCMP(p, "shift:", 6) == 0
- && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
- {
- p += 6;
- bri_shift = getdigits(&p);
- }
- else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
- {
- p += 4;
- bri_min = getdigits(&p);
- }
- else if (STRNCMP(p, "sbr", 3) == 0)
- {
- p += 3;
- bri_sbr = TRUE;
- }
- if (*p != ',' && *p != NUL)
- return FAIL;
- if (*p == ',')
- ++p;
- }
-
- wp->w_p_brishift = bri_shift;
- wp->w_p_brimin = bri_min;
- wp->w_p_brisbr = bri_sbr;
-
- return OK;
-}
-#endif
-
-/*
* Get the local or global value of 'backupcopy'.
*/
unsigned int
diff --git a/src/proto/change.pro b/src/proto/change.pro
index c31c442a50..badb19dbdf 100644
--- a/src/proto/change.pro
+++ b/src/proto/change.pro
@@ -15,6 +15,8 @@ void deleted_lines(linenr_T lnum, long count);
void deleted_lines_mark(linenr_T lnum, long count);
void changed_lines(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra);
void unchanged(buf_T *buf, int ff, int always_inc_changedtick);
+void save_file_ff(buf_T *buf);
+int file_ff_differs(buf_T *buf, int ignore_empty);
void ins_bytes(char_u *p);
void ins_bytes_len(char_u *p, int len);
void ins_char(int c);
diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro
index a2f092df57..a8ca7af17b 100644
--- a/src/proto/ex_getln.pro
+++ b/src/proto/ex_getln.pro
@@ -2,6 +2,7 @@
void cmdline_init(void);
char_u *getcmdline(int firstc, long count, int indent, int do_concat);
char_u *getcmdline_prompt(int firstc, char_u *prompt, int attr, int xp_context, char_u *xp_arg);
+int check_opt_wim(void);
int text_locked(void);
void text_locked_msg(void);
char *get_text_locked_msg(void);
@@ -35,6 +36,7 @@ void f_getcmdtype(typval_T *argvars, typval_T *rettv);
int get_cmdline_type(void);
int get_cmdline_firstc(void);
int get_list_range(char_u **str, int *num1, int *num2);
+char *check_cedit(void);
char_u *script_get(exarg_T *eap, char_u *cmd);
void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog, int secret);
/* vim: set ft=c : */
diff --git a/src/proto/gui.pro b/src/proto/gui.pro
index a49ecad4c5..7f2ce90068 100644
--- a/src/proto/gui.pro
+++ b/src/proto/gui.pro
@@ -49,6 +49,8 @@ int gui_do_horiz_scroll(long_u leftcol, int compute_longest_lnum);
void gui_check_colors(void);
guicolor_T gui_get_color(char_u *name);
int gui_get_lightness(guicolor_T pixel);
+char_u *gui_bg_default(void);
+void init_gui_options(void);
void gui_new_scrollbar_colors(void);
void gui_focus_change(int in_focus);
void gui_mouse_moved(int x, int y);
diff --git a/src/proto/indent.pro b/src/proto/indent.pro
index 2aed373a61..a42f20f0d6 100644
--- a/src/proto/indent.pro
+++ b/src/proto/indent.pro
@@ -18,6 +18,7 @@ int get_indent_str(char_u *ptr, int ts, int list);
int get_indent_str_vtab(char_u *ptr, int ts, int *vts, int list);
int set_indent(int size, int flags);
int get_number_indent(linenr_T lnum);
+int briopt_check(win_T *wp);
int get_breakindent_win(win_T *wp, char_u *line);
int inindent(int extra);
void op_reindent(oparg_T *oap, int (*how)(void));
diff --git a/src/proto/option.pro b/src/proto/option.pro
index b3250dca72..dc07ee6b83 100644
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -7,12 +7,10 @@ void free_all_options(void);
void set_init_2(void);
void set_init_3(void);
void set_helplang_default(char_u *lang);
-void init_gui_options(void);
void set_title_defaults(void);
int do_set(char_u *arg, int opt_flags);
void did_set_option(int opt_idx, int opt_flags, int new_value, int value_checked);
int string_to_key(char_u *arg, int multi_byte);
-char *check_cedit(void);
void did_set_title(void);
void set_options_bin(int oldval, int newval, int opt_flags);
void check_options(void);
@@ -21,7 +19,6 @@ int set_term_option_alloced(char_u **p);
int was_set_insecurely(char_u *opt, int opt_flags);
void redraw_titles(void);
int valid_name(char_u *val, char *allowed);
-char *check_clipboard_option(void);
void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx);
void set_term_option_sctx_idx(char *name, int opt_idx);
void check_redraw(long_u flags);
@@ -71,14 +68,9 @@ void change_compatible(int on);
int option_was_set(char_u *name);
int reset_option_was_set(char_u *name);
void fill_breakat_flags(void);
-int check_opt_wim(void);
int can_bs(int what);
-void save_file_ff(buf_T *buf);
-int file_ff_differs(buf_T *buf, int ignore_empty);
long get_scrolloff_value(void);
long get_sidescrolloff_value(void);
-void find_mps_values(int *initc, int *findc, int *backwards, int switchit);
-int briopt_check(win_T *wp);
unsigned int get_bkc_value(buf_T *buf);
char_u *get_showbreak_value(win_T *win);
dict_T *get_winbuf_options(int bufopt);
diff --git a/src/proto/term.pro b/src/proto/term.pro
index b29eace07a..5af1996147 100644
--- a/src/proto/term.pro
+++ b/src/proto/term.pro
@@ -25,6 +25,7 @@ int term_get_winpos(int *x, int *y, varnumber_T timeout);
void term_set_winsize(int height, int width);
void term_fg_color(int n);
void term_bg_color(int n);
+char_u *term_bg_default(void);
void term_fg_rgb_color(guicolor_T rgb);
void term_bg_rgb_color(guicolor_T rgb);
void term_settitle(char_u *title);
diff --git a/src/proto/ui.pro b/src/proto/ui.pro
index 7ba82cd054..e605649f36 100644
--- a/src/proto/ui.pro
+++ b/src/proto/ui.pro
@@ -35,6 +35,7 @@ void clip_copy_modeless_selection(int both);
void clip_gen_set_selection(Clipboard_T *cbd);
void clip_gen_request_selection(Clipboard_T *cbd);
int clip_gen_owner_exists(Clipboard_T *cbd);
+char *check_clipboard_option(void);
int vim_is_input_buf_full(void);
int vim_is_input_buf_empty(void);
int vim_free_in_input_buf(void);
@@ -43,7 +44,6 @@ char_u *get_input_buf(void);
void set_input_buf(char_u *p);
void add_to_input_buf(char_u *s, int len);
void add_to_input_buf_csi(char_u *str, int len);
-void push_raw_key(char_u *s, int len);
void trash_input_buf(void);
int read_from_input_buf(char_u *buf, long maxlen);
void fill_input_buf(int exit_on_error);
diff --git a/src/term.c b/src/term.c
index 5b8901ed12..83268c71c5 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2898,6 +2898,40 @@ term_bg_color(int n)
term_color(T_CSB, n);
}
+/*
+ * Return "dark" or "light" depending on the kind of terminal.
+ * This is just guessing! Recognized are:
+ * "linux" Linux console
+ * "screen.linux" Linux console with screen
+ * "cygwin.*" Cygwin shell
+ * "putty.*" Putty program
+ * We also check the COLORFGBG environment variable, which is set by
+ * rxvt and derivatives. This variable contains either two or three
+ * values separated by semicolons; we want the last value in either
+ * case. If this value is 0-6 or 8, our background is dark.
+ */
+ char_u *
+term_bg_default(void)
+{
+#if defined(MSWIN)
+ /* DOS console is nearly always black */
+ return (char_u *)"dark";
+#else
+ char_u *p;
+
+ if (STRCMP(T_NAME, "linux") == 0
+ || STRCMP(T_NAME, "screen.linux") == 0
+ || STRNCMP(T_NAME, "cygwin", 6) == 0
+ || STRNCMP(T_NAME, "putty", 5) == 0
+ || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
+ && (p = vim_strrchr(p, ';')) != NULL
+ && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
+ && p[2] == NUL))
+ return (char_u *)"dark";
+ return (char_u *)"light";
+#endif
+}
+
#if defined(FEAT_TERMGUICOLORS) || defined(PROTO)
#define RED(rgb) (((long_u)(rgb) >> 16) & 0xFF)
diff --git a/src/ui.c b/src/ui.c
index f31af838f1..1eaaec3f24 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -1944,7 +1944,98 @@ clip_gen_owner_exists(Clipboard_T *cbd UNUSED)
}
#endif
-#endif /* FEAT_CLIPBOARD */
+/*
+ * Extract the items in the 'clipboard' option and set global values.
+ * Return an error message or NULL for success.
+ */
+ char *
+check_clipboard_option(void)
+{
+ int new_unnamed = 0;
+ int new_autoselect_star = FALSE;
+ int new_autoselect_plus = FALSE;
+ int new_autoselectml = FALSE;
+ int new_html = FALSE;
+ regprog_T *new_exclude_prog = NULL;
+ char *errmsg = NULL;
+ char_u *p;
+
+ for (p = p_cb; *p != NUL; )
+ {
+ if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
+ {
+ new_unnamed |= CLIP_UNNAMED;
+ p += 7;
+ }
+ else if (STRNCMP(p, "unnamedplus", 11) == 0
+ && (p[11] == ',' || p[11] == NUL))
+ {
+ new_unnamed |= CLIP_UNNAMED_PLUS;
+ p += 11;
+ }
+ else if (STRNCMP(p, "autoselect", 10) == 0
+ && (p[10] == ',' || p[10] == NUL))
+ {
+ new_autoselect_star = TRUE;
+ p += 10;
+ }
+ else if (STRNCMP(p, "autoselectplus", 14) == 0
+ && (p[14] == ',' || p[14] == NUL))
+ {
+ new_autoselect_plus = TRUE;
+ p += 14;
+ }
+ else if (STRNCMP(p, "autoselectml", 12) == 0
+ && (p[12] == ',' || p[12] == NUL))
+ {
+ new_autoselectml = TRUE;
+ p += 12;
+ }
+ else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
+ {
+ new_html = TRUE;
+ p += 4;
+ }
+ else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
+ {
+ p += 8;
+ new_exclude_prog = vim_regcomp(p, RE_MAGIC);
+ if (new_exclude_prog == NULL)
+ errmsg = e_invarg;
+ break;
+ }
+ else
+ {
+ errmsg = e_invarg;
+ break;
+ }
+ if (*p == ',')
+ ++p;
+ }
+ if (errmsg == NULL)
+ {
+ clip_unnamed = new_unnamed;
+ clip_autoselect_star = new_autoselect_star;
+ clip_autoselect_plus = new_autoselect_plus;
+ clip_autoselectml = new_autoselectml;
+ clip_html = new_html;
+ vim_regfree(clip_exclude_prog);
+ clip_exclude_prog = new_exclude_prog;
+#ifdef FEAT_GUI_GTK
+ if (gui.in_use)
+ {
+ gui_gtk_set_selection_targets();
+ gui_gtk_set_dnd_targets();
+ }
+#endif
+ }
+ else
+ vim_regfree(new_exclude_prog);
+
+ return errmsg;
+}
+
+#endif // FEAT_CLIPBOARD
/*****************************************************************************
* Functions that handle the input buffer.
diff --git a/src/version.c b/src/version.c
index 41bd4cc6a4..db3a6637ea 100644
--- a/src/version.c
+++ b/src/version.c
@@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2331,
+/**/
2330,
/**/
2329,