mirror of
https://github.com/vim/vim.git
synced 2025-10-22 08:34:29 -04:00
patch 9.1.1860: clipboard register "+" enabled with cplipboard provider feature
Problem: clipboard register "+" enabled with cplipboard provider feature (BenYip, after v9.1.1857) Solution: Don't make clipboard provider enable plus register on UNIX (Foxe Chen) fixes: #18580 closes: #18580 Signed-off-by: Foxe Chen <chen.foxe@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
6180d65751
commit
761a484e12
@@ -1,4 +1,4 @@
|
|||||||
*eval.txt* For Vim version 9.1. Last change: 2025 Oct 14
|
*eval.txt* For Vim version 9.1. Last change: 2025 Oct 16
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@@ -5274,8 +5274,9 @@ Usage: >vim
|
|||||||
|
|
||||||
When Vim is compiled with the |+clipboard_provider| feature, which requires
|
When Vim is compiled with the |+clipboard_provider| feature, which requires
|
||||||
the |+eval| feature, creating custom clipboards is possible. These providers
|
the |+eval| feature, creating custom clipboards is possible. These providers
|
||||||
handle the "+" and "*" registers. Note that on non-Unix or non-VMS systems,
|
handle the "+" and "*" registers. Note that if |+wayland_clipboard| or
|
||||||
only the "*" register will be available for use.
|
|+xterm_clipboard| features are not compiled in, then the "+" register will
|
||||||
|
not be available.
|
||||||
|
|
||||||
To add a provider, add a new entry to the |v:clipproviders| dictionary, in the
|
To add a provider, add a new entry to the |v:clipproviders| dictionary, in the
|
||||||
format of: >
|
format of: >
|
||||||
@@ -5353,7 +5354,7 @@ Here is an example script that uses the clipboard provider feature through the
|
|||||||
OSC52 command: >vim
|
OSC52 command: >vim
|
||||||
|
|
||||||
func Available()
|
func Available()
|
||||||
return "+"
|
return "*"
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Paste(reg, type)
|
func Paste(reg, type)
|
||||||
@@ -5368,7 +5369,7 @@ OSC52 command: >vim
|
|||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Send command
|
" Send command
|
||||||
call echoraw("\<Esc>]52;c;?\<Esc>\\")
|
call echoraw("\<Esc>]52;;?\<Esc>\\")
|
||||||
|
|
||||||
" Wait until autocmd is triggered
|
" Wait until autocmd is triggered
|
||||||
while getchar(-1) != "\<F30>"
|
while getchar(-1) != "\<F30>"
|
||||||
@@ -5377,7 +5378,7 @@ OSC52 command: >vim
|
|||||||
autocmd! OSC
|
autocmd! OSC
|
||||||
|
|
||||||
" Extract the base64 stuff
|
" Extract the base64 stuff
|
||||||
let l:stuff = matchstr(v:termosc, '52;c;\zs[A-Za-z0-9+/=]\+')
|
let l:stuff = matchstr(v:termosc, '52;.\+;\zs[A-Za-z0-9+/=]\+')
|
||||||
|
|
||||||
return ("", blob2str(base64_decode(l:stuff)))
|
return ("", blob2str(base64_decode(l:stuff)))
|
||||||
endfunc
|
endfunc
|
||||||
@@ -5389,10 +5390,10 @@ OSC52 command: >vim
|
|||||||
let v:clipproviders["myosc"] = {
|
let v:clipproviders["myosc"] = {
|
||||||
\ "available": function("Available"),
|
\ "available": function("Available"),
|
||||||
\ "paste": {
|
\ "paste": {
|
||||||
\ '+': function("Paste"),
|
\ '*': function("Paste")
|
||||||
\ },
|
\ },
|
||||||
\ "copy": {
|
\ "copy": {
|
||||||
\ '+': function("Copy"),
|
\ '*': function("Copy")
|
||||||
\ },
|
\ },
|
||||||
\ }
|
\ }
|
||||||
set clipmethod=myosc
|
set clipmethod=myosc
|
||||||
|
@@ -3466,7 +3466,7 @@ clip_wl_owner_exists(Clipboard_T *cbd)
|
|||||||
* depending on the order of values in str.
|
* depending on the order of values in str.
|
||||||
*/
|
*/
|
||||||
static clipmethod_T
|
static clipmethod_T
|
||||||
get_clipmethod(char_u *str, bool *regular, bool *primary)
|
get_clipmethod(char_u *str, bool *plus UNUSED, bool *star)
|
||||||
{
|
{
|
||||||
int len = (int)STRLEN(str) + 1;
|
int len = (int)STRLEN(str) + 1;
|
||||||
char_u *buf = alloc(len);
|
char_u *buf = alloc(len);
|
||||||
@@ -3493,8 +3493,8 @@ get_clipmethod(char_u *str, bool *regular, bool *primary)
|
|||||||
if (clip_wl.regular.available || clip_wl.primary.available)
|
if (clip_wl.regular.available || clip_wl.primary.available)
|
||||||
{
|
{
|
||||||
method = CLIPMETHOD_WAYLAND;
|
method = CLIPMETHOD_WAYLAND;
|
||||||
*regular = clip_wl.regular.available;
|
*plus = clip_wl.regular.available;
|
||||||
*primary = clip_wl.primary.available;
|
*star = clip_wl.primary.available;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -3516,7 +3516,7 @@ get_clipmethod(char_u *str, bool *regular, bool *primary)
|
|||||||
// won't be executed since xterm_dpy will be set to NULL.
|
// won't be executed since xterm_dpy will be set to NULL.
|
||||||
xterm_update();
|
xterm_update();
|
||||||
method = CLIPMETHOD_X11;
|
method = CLIPMETHOD_X11;
|
||||||
*regular = *primary = true;
|
*plus = *star = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -3527,7 +3527,7 @@ get_clipmethod(char_u *str, bool *regular, bool *primary)
|
|||||||
if (gui.in_use)
|
if (gui.in_use)
|
||||||
{
|
{
|
||||||
method = CLIPMETHOD_GUI;
|
method = CLIPMETHOD_GUI;
|
||||||
*regular = *primary = true;
|
*star = *plus = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -3535,27 +3535,40 @@ get_clipmethod(char_u *str, bool *regular, bool *primary)
|
|||||||
{
|
{
|
||||||
#ifndef UNIX
|
#ifndef UNIX
|
||||||
method = CLIPMETHOD_OTHER;
|
method = CLIPMETHOD_OTHER;
|
||||||
*regular = *primary = true;
|
*plus = *star = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef FEAT_CLIPBOARD_PROVIDER
|
#ifdef FEAT_CLIPBOARD_PROVIDER
|
||||||
// Check if it is the name of a provider
|
// Check if it is the name of a provider
|
||||||
int reg = clip_provider_is_available(&clip_plus, buf);
|
#ifndef ONE_CLIPBOARD
|
||||||
int pri = clip_provider_is_available(&clip_star, buf);
|
int plus_avail = clip_provider_is_available(&clip_plus, buf);
|
||||||
|
#endif
|
||||||
|
int star_avail = clip_provider_is_available(&clip_star, buf);
|
||||||
|
|
||||||
if (reg == 1 || pri == 1)
|
if (
|
||||||
|
#ifndef ONE_CLIPBOARD
|
||||||
|
plus_avail == 1 ||
|
||||||
|
#endif
|
||||||
|
star_avail == 1)
|
||||||
{
|
{
|
||||||
method = CLIPMETHOD_PROVIDER;
|
method = CLIPMETHOD_PROVIDER;
|
||||||
|
|
||||||
vim_free(clipprovider_name);
|
vim_free(clipprovider_name);
|
||||||
clipprovider_name = vim_strsave(buf);
|
clipprovider_name = vim_strsave(buf);
|
||||||
|
|
||||||
*regular = reg == 1;
|
#ifndef ONE_CLIPBOARD
|
||||||
*primary = pri == 1;
|
*plus = plus_avail == 1;
|
||||||
|
#endif
|
||||||
|
*star = star_avail == 1;
|
||||||
}
|
}
|
||||||
else if (reg == -1)
|
|
||||||
|
else if (
|
||||||
|
#ifndef ONE_CLIPBOARD
|
||||||
|
plus_avail == -1 ||
|
||||||
|
#endif
|
||||||
|
star_avail == -1)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ret = CLIPMETHOD_FAIL;
|
ret = CLIPMETHOD_FAIL;
|
||||||
@@ -3614,8 +3627,9 @@ clipmethod_to_str(clipmethod_T method)
|
|||||||
char *
|
char *
|
||||||
choose_clipmethod(void)
|
choose_clipmethod(void)
|
||||||
{
|
{
|
||||||
bool regular = false, primary = false;
|
bool plus = false;
|
||||||
clipmethod_T method = get_clipmethod(p_cpm, ®ular, &primary);
|
bool star = false;
|
||||||
|
clipmethod_T method = get_clipmethod(p_cpm, &plus, &star);
|
||||||
|
|
||||||
if (method == CLIPMETHOD_FAIL)
|
if (method == CLIPMETHOD_FAIL)
|
||||||
return e_invalid_argument;
|
return e_invalid_argument;
|
||||||
@@ -3633,9 +3647,11 @@ choose_clipmethod(void)
|
|||||||
// If we have a clipmethod that works now, then initialize clipboard
|
// If we have a clipmethod that works now, then initialize clipboard
|
||||||
else if (clipmethod == CLIPMETHOD_NONE && method != CLIPMETHOD_NONE)
|
else if (clipmethod == CLIPMETHOD_NONE && method != CLIPMETHOD_NONE)
|
||||||
{
|
{
|
||||||
clip_init_single(&clip_plus, regular);
|
#ifndef ONE_CLIPBOARD
|
||||||
clip_init_single(&clip_star, primary);
|
clip_init_single(&clip_plus, plus);
|
||||||
clip_plus.did_warn = false;
|
clip_plus.did_warn = false;
|
||||||
|
#endif
|
||||||
|
clip_init_single(&clip_star, star);
|
||||||
clip_star.did_warn = false;
|
clip_star.did_warn = false;
|
||||||
}
|
}
|
||||||
else if ((clipmethod != CLIPMETHOD_NONE && method != clipmethod))
|
else if ((clipmethod != CLIPMETHOD_NONE && method != clipmethod))
|
||||||
@@ -3643,20 +3659,23 @@ choose_clipmethod(void)
|
|||||||
// Disown clipboard if we are switching to a new method
|
// Disown clipboard if we are switching to a new method
|
||||||
if (clip_star.owned)
|
if (clip_star.owned)
|
||||||
clip_lose_selection(&clip_star);
|
clip_lose_selection(&clip_star);
|
||||||
|
clip_init_single(&clip_star, star);
|
||||||
|
#ifndef ONE_CLIPBOARD
|
||||||
if (clip_plus.owned)
|
if (clip_plus.owned)
|
||||||
clip_lose_selection(&clip_plus);
|
clip_lose_selection(&clip_plus);
|
||||||
|
clip_init_single(&clip_plus, plus);
|
||||||
clip_init_single(&clip_plus, regular);
|
#endif
|
||||||
clip_init_single(&clip_star, primary);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If availability of a clipboard changed, then update the clipboard
|
// If availability of a clipboard changed, then update the clipboard
|
||||||
// structure.
|
// structure.
|
||||||
if (regular != clip_plus.available)
|
#ifndef ONE_CLIPBOARD
|
||||||
clip_init_single(&clip_plus, regular);
|
if (plus != clip_plus.available)
|
||||||
if (primary != clip_star.available)
|
clip_init_single(&clip_plus, plus);
|
||||||
clip_init_single(&clip_star, primary);
|
#endif
|
||||||
|
if (star != clip_star.available)
|
||||||
|
clip_init_single(&clip_star, star);
|
||||||
}
|
}
|
||||||
|
|
||||||
clipmethod = method;
|
clipmethod = method;
|
||||||
@@ -3724,8 +3743,12 @@ clip_provider_is_available(Clipboard_T *cbd, char_u *provider)
|
|||||||
|
|
||||||
avail = rettv.vval.v_string;
|
avail = rettv.vval.v_string;
|
||||||
|
|
||||||
if ((vim_strchr(avail, '+') != NULL && cbd == &clip_plus)
|
|
||||||
|| (vim_strchr(avail, '*') != NULL && cbd == &clip_star))
|
if (
|
||||||
|
#ifndef ONE_CLIPBOARD
|
||||||
|
(vim_strchr(avail, '+') != NULL && cbd == &clip_plus) ||
|
||||||
|
#endif
|
||||||
|
(vim_strchr(avail, '*') != NULL && cbd == &clip_star))
|
||||||
res = 1;
|
res = 1;
|
||||||
|
|
||||||
if (FALSE)
|
if (FALSE)
|
||||||
|
@@ -972,8 +972,7 @@ EXTERN int gui_win_y INIT(= -1);
|
|||||||
|
|
||||||
#ifdef FEAT_CLIPBOARD
|
#ifdef FEAT_CLIPBOARD
|
||||||
EXTERN Clipboard_T clip_star; // PRIMARY selection in X11/Wayland
|
EXTERN Clipboard_T clip_star; // PRIMARY selection in X11/Wayland
|
||||||
# if defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD) \
|
# if defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD)
|
||||||
|| ((defined(UNIX) || defined(VMS)) && defined(FEAT_CLIPBOARD_PROVIDER))
|
|
||||||
EXTERN Clipboard_T clip_plus; // CLIPBOARD selection in X11/Wayland
|
EXTERN Clipboard_T clip_plus; // CLIPBOARD selection in X11/Wayland
|
||||||
# else
|
# else
|
||||||
# define clip_plus clip_star // there is only one clipboard
|
# define clip_plus clip_star // there is only one clipboard
|
||||||
|
@@ -734,6 +734,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1860,
|
||||||
/**/
|
/**/
|
||||||
1859,
|
1859,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user