diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-11-21 22:14:18 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-11-21 22:14:18 +0100 |
commit | 7bae0b1bc84a95d565ffab38cf7f82ad21c656b6 (patch) | |
tree | 2d724ddd855892ef212f14924e2cc04feafa5abe /src/ui.c | |
parent | 94d9f4fa65bce6f116cf89bfdabdf5a06509056f (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)
Diffstat (limited to 'src/ui.c')
-rw-r--r-- | src/ui.c | 93 |
1 files changed, 92 insertions, 1 deletions
@@ -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. |