diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2014-09-30 18:04:22 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2014-12-08 22:05:05 +0100 |
commit | 5476250ba3208c92cc9865becf540fdd335c2927 (patch) | |
tree | a8c7a06d49f0cc4ab8ef8bc1aad52f65e1af8e82 | |
parent | 61aaf815dbf42c11947748656f377f578c4ed4c7 (diff) | |
download | rneovim-5476250ba3208c92cc9865becf540fdd335c2927.tar.gz rneovim-5476250ba3208c92cc9865becf540fdd335c2927.tar.bz2 rneovim-5476250ba3208c92cc9865becf540fdd335c2927.zip |
options: change "unnamedclip" back to "clipboard=unnamed/unnamedplus"
This allows to configure which of '*' and '+' should be used for
the unnamed clipboard, and is consistent with vim.
-rw-r--r-- | src/nvim/ops.c | 26 | ||||
-rw-r--r-- | src/nvim/option.c | 10 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 8 |
3 files changed, 29 insertions, 15 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index b19140813f..e8cad24b92 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -60,6 +60,7 @@ #define DELETION_REGISTER 36 #define CLIP_REGISTER 37 +# define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS) /* * Each yank register is an array of pointers to lines. */ @@ -751,7 +752,8 @@ void get_yank_register(int regname, int writing) int i; y_append = FALSE; - if ((regname == 0 || regname == '"') && !p_unc && !writing && y_previous != NULL) { + int unnamedclip = cb_flags & CB_UNNAMEDMASK; + if ((regname == 0 || regname == '"') && !unnamedclip && !writing && y_previous != NULL) { y_current = y_previous; return; } @@ -1378,9 +1380,10 @@ int op_delete(oparg_T *oap) * register. For the black hole register '_' don't yank anything. */ if (oap->regname != '_') { - if (oap->regname != 0 || p_unc) { + bool unnamedclip = oap->regname == 0 && (cb_flags & CB_UNNAMEDMASK); + if (oap->regname != 0 || unnamedclip) { /* check for read-only register */ - if (!( valid_yank_reg(oap->regname, TRUE) || (p_unc && oap->regname == 0) )) { + if (!( valid_yank_reg(oap->regname, TRUE) || unnamedclip )) { beep_flush(); return OK; } @@ -5204,18 +5207,23 @@ static void free_register(struct yankreg *reg) y_current = curr; } +// return target register static int check_clipboard_name(int *name) { if (*name == '*' || *name == '+') { return CLIP_REGISTER; - } else if (p_unc && *name == NUL && eval_has_provider("clipboard")) { - *name = '+'; - return 0; //unnamed register - } else { - return -1; + } else if (*name == NUL && eval_has_provider("clipboard")) { + if (cb_flags & CB_UNNAMEDPLUS) { + *name = '+'; + return 0; //unnamed + } else if (cb_flags & CB_UNNAMED) { + *name = '*'; + return 0; //unnamed + } } + // don't do anything for other register names + return -1; } - static void get_clipboard(int name) { int ireg = check_clipboard_name(&name); diff --git a/src/nvim/option.c b/src/nvim/option.c index 2882d7a511..fd0978f3a6 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -527,7 +527,7 @@ static struct vimoption (char_u *)0L} SCRIPTID_INIT}, {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, - (char_u *)NULL, PV_NONE, + (char_u *)&p_cb, PV_NONE, {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL, @@ -1620,9 +1620,6 @@ static struct vimoption {"undoreload", "ur", P_NUM|P_VI_DEF, (char_u *)&p_ur, PV_NONE, { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT}, - {"unnamedclip", "ucp", P_BOOL|P_VI_DEF|P_VIM, - (char_u *)&p_unc, PV_NONE, - {(char_u *)FALSE, (char_u *)FALSE} SCRIPTID_INIT}, {"updatecount", "uc", P_NUM|P_VI_DEF, (char_u *)&p_uc, PV_NONE, {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT}, @@ -4279,6 +4276,10 @@ did_set_string_option ( if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK) errmsg = e_invarg; } + else if (varp == &p_cb) { + if (opt_strings_flags(p_cb, p_cb_values, &cb_flags, TRUE) != OK) + errmsg = e_invarg; + } /* When 'spelllang' or 'spellfile' is set and there is a window for this * buffer in which 'spell' is set load the wordlists. */ else if (varp == &(curbuf->b_s.b_p_spl) || varp == &(curbuf->b_s.b_p_spf)) { @@ -4846,7 +4847,6 @@ char_u *check_stl_option(char_u *s) return NULL; } - /* * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'. * Return error message when failed, NULL when OK. diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 89264f8982..39dfbe8b88 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -317,6 +317,13 @@ EXTERN char_u *p_enc; /* 'encoding' */ EXTERN int p_deco; /* 'delcombine' */ EXTERN char_u *p_ccv; /* 'charconvert' */ EXTERN char_u *p_cedit; /* 'cedit' */ +EXTERN char_u *p_cb; /* 'clipboard' */ +EXTERN unsigned cb_flags; +#ifdef IN_OPTION_C +static char *(p_cb_values[]) = {"unnamed", "unnamedplus", NULL}; +#endif +# define CB_UNNAMED 0x001 +# define CB_UNNAMEDPLUS 0x002 EXTERN long p_cwh; /* 'cmdwinheight' */ EXTERN long p_ch; /* 'cmdheight' */ EXTERN int p_confirm; /* 'confirm' */ @@ -582,7 +589,6 @@ static char *(p_ttym_values[]) = EXTERN char_u *p_udir; /* 'undodir' */ EXTERN long p_ul; /* 'undolevels' */ EXTERN long p_ur; /* 'undoreload' */ -EXTERN int p_unc; /* 'unnamedclip' */ EXTERN long p_uc; /* 'updatecount' */ EXTERN long p_ut; /* 'updatetime' */ EXTERN char_u *p_fcs; /* 'fillchar' */ |