diff src/ops.c @ 19774:00a1b89256ea v8.2.0443

patch 8.2.0443: clipboard code is spread out Commit: https://github.com/vim/vim/commit/45fffdf10b7cb6e59794e76e9b8a2930fcb4b192 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 24 21:42:01 2020 +0100 patch 8.2.0443: clipboard code is spread out Problem: Clipboard code is spread out. Solution: Move clipboard code to its own file. (Yegappan Lakshmanan, closes #5827)
author Bram Moolenaar <Bram@vim.org>
date Tue, 24 Mar 2020 21:45:04 +0100
parents 9daed26b788b
children aadd1cae2ff5
line wrap: on
line diff
--- a/src/ops.c
+++ b/src/ops.c
@@ -3409,113 +3409,6 @@ theend:
     return did_change;
 }
 
-#if defined(FEAT_CLIPBOARD) || defined(PROTO)
-/*
- * SELECTION / PRIMARY ('*')
- *
- * Text selection stuff that uses the GUI selection register '*'.  When using a
- * GUI this may be text from another window, otherwise it is the last text we
- * had highlighted with VIsual mode.  With mouse support, clicking the middle
- * button performs the paste, otherwise you will need to do <"*p>. "
- * If not under X, it is synonymous with the clipboard register '+'.
- *
- * X CLIPBOARD ('+')
- *
- * Text selection stuff that uses the GUI clipboard register '+'.
- * Under X, this matches the standard cut/paste buffer CLIPBOARD selection.
- * It will be used for unnamed cut/pasting is 'clipboard' contains "unnamed",
- * otherwise you will need to do <"+p>. "
- * If not under X, it is synonymous with the selection register '*'.
- */
-
-/*
- * Routine to export any final X selection we had to the environment
- * so that the text is still available after Vim has exited. X selections
- * only exist while the owning application exists, so we write to the
- * permanent (while X runs) store CUT_BUFFER0.
- * Dump the CLIPBOARD selection if we own it (it's logically the more
- * 'permanent' of the two), otherwise the PRIMARY one.
- * For now, use a hard-coded sanity limit of 1Mb of data.
- */
-#if (defined(FEAT_X11) && defined(FEAT_CLIPBOARD)) || defined(PROTO)
-    void
-x11_export_final_selection(void)
-{
-    Display	*dpy;
-    char_u	*str = NULL;
-    long_u	len = 0;
-    int		motion_type = -1;
-
-# ifdef FEAT_GUI
-    if (gui.in_use)
-	dpy = X_DISPLAY;
-    else
-# endif
-# ifdef FEAT_XCLIPBOARD
-	dpy = xterm_dpy;
-# else
-	return;
-# endif
-
-    // Get selection to export
-    if (clip_plus.owned)
-	motion_type = clip_convert_selection(&str, &len, &clip_plus);
-    else if (clip_star.owned)
-	motion_type = clip_convert_selection(&str, &len, &clip_star);
-
-    // Check it's OK
-    if (dpy != NULL && str != NULL && motion_type >= 0
-					       && len < 1024*1024 && len > 0)
-    {
-	int ok = TRUE;
-
-	// The CUT_BUFFER0 is supposed to always contain latin1.  Convert from
-	// 'enc' when it is a multi-byte encoding.  When 'enc' is an 8-bit
-	// encoding conversion usually doesn't work, so keep the text as-is.
-	if (has_mbyte)
-	{
-	    vimconv_T	vc;
-
-	    vc.vc_type = CONV_NONE;
-	    if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK)
-	    {
-		int	intlen = len;
-		char_u	*conv_str;
-
-		vc.vc_fail = TRUE;
-		conv_str = string_convert(&vc, str, &intlen);
-		len = intlen;
-		if (conv_str != NULL)
-		{
-		    vim_free(str);
-		    str = conv_str;
-		}
-		else
-		{
-		    ok = FALSE;
-		}
-		convert_setup(&vc, NULL, NULL);
-	    }
-	    else
-	    {
-		ok = FALSE;
-	    }
-	}
-
-	// Do not store the string if conversion failed.  Better to use any
-	// other selection than garbled text.
-	if (ok)
-	{
-	    XStoreBuffer(dpy, (char *)str, (int)len, 0);
-	    XFlush(dpy);
-	}
-    }
-
-    vim_free(str);
-}
-#endif
-#endif // FEAT_CLIPBOARD || PROTO
-
     void
 clear_oparg(oparg_T *oap)
 {