aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2015-04-08 21:46:12 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2015-04-11 11:11:52 +0200
commit941b02af4cca9fb98c6ee4a8dd4aa800bd337deb (patch)
treed3a1a5a907bf3c8c1ef3501e3a01afdbee375f1b /src/nvim/ops.c
parente584fe00570a522154ce856581006644e766f88f (diff)
downloadrneovim-941b02af4cca9fb98c6ee4a8dd4aa800bd337deb.tar.gz
rneovim-941b02af4cca9fb98c6ee4a8dd4aa800bd337deb.tar.bz2
rneovim-941b02af4cca9fb98c6ee4a8dd4aa800bd337deb.zip
clipboard: adjust v:register when clipboard=unnamed
Helped-By: Nicolas Hillegeer <nicolas@hillegeer.com> Helped-By: Michael Reed <m.reed@mykolab.com>
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 4c5a002f81..54c2edf4fa 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5310,7 +5310,28 @@ static void free_register(struct yankreg *reg)
y_current = curr;
}
-// return target register
+/// Check if the default register (used in an unnamed paste) should be a
+/// clipboard register. This happens when `clipboard=unnamed[plus]` is set
+/// and a provider is available.
+///
+/// @returns the name of of a clipboard register that should be used, or `NUL` if none.
+int get_default_register_name(void)
+{
+ int name = NUL;
+ adjust_clipboard_name(&name, true, false);
+ return name;
+}
+
+/// Determine if register `*name` should be used as a clipboard.
+/// In an unnammed operation, `*name` is `NUL` and will be adjusted to `'*'/'+'` if
+/// `clipboard=unnamed[plus]` is set.
+///
+/// @param name The name of register, or `NUL` if unnamed.
+/// @param quiet Suppress error messages
+/// @param writing if we're setting the contents of the clipboard
+///
+/// @returns the yankreg that should be used, or `NULL`
+/// if the register isn't a clipboard or provider isn't available.
static struct yankreg* adjust_clipboard_name(int *name, bool quiet, bool writing) {
if (*name == '*' || *name == '+') {
if(!eval_has_provider("clipboard")) {