From c1854d2433a10122ae2933e2dcbc970b53e9438b Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 22 Nov 2014 16:01:14 +0100 Subject: clipboard: support separate '+' and '*' clipboards --- src/nvim/eval.c | 14 ++++++++++++++ src/nvim/ops.c | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index be69bdbe61..c2156c5d58 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5118,6 +5118,20 @@ void list_append_tv(list_T *l, typval_T *tv) list_append(l, li); } +/* + * Add a list to a list. + */ +void list_append_list(list_T *list, list_T *itemlist) +{ + listitem_T *li = listitem_alloc(); + + li->li_tv.v_type = VAR_LIST; + li->li_tv.v_lock = 0; + li->li_tv.vval.v_list = itemlist; + list_append(list, li); + ++list->lv_refcount; +} + /* * Add a dictionary to a list. Used by getqflist(). */ diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 6bf3f6036f..8dfb986714 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5244,7 +5244,11 @@ static void get_clipboard(int name) struct yankreg *reg = &y_regs[CLIP_REGISTER]; free_register(reg); + list_T *args = list_alloc(); + char_u regname = (char_u)name; + list_append_string(args, ®name, 1); + typval_T result = eval_call_provider("clipboard", "get", args); if (result.v_type != VAR_LIST) { @@ -5294,6 +5298,7 @@ static void set_clipboard(int name) if (!name && p_unc) { // copy from the unnamed register copy_register(reg, &y_regs[0]); + name = '+'; } list_T *lines = list_alloc(); @@ -5302,5 +5307,11 @@ static void set_clipboard(int name) list_append_string(lines, reg->y_array[i], -1); } - (void)eval_call_provider("clipboard", "set", lines); + list_T *args = list_alloc(); + list_append_list(args, lines); + + char_u regname = (char_u)name; + list_append_string(args, ®name, 1); + + (void)eval_call_provider("clipboard", "set", args); } -- cgit