[hackers] [st][PATCH] Add option: synchronize clipboards

From: cnfn <cnfnss_AT_gmail.com>
Date: Sun, 10 Jul 2016 02:28:27 +0800

---
 st.1 |  8 +++++++-
 st.c | 10 ++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/st.1 b/st.1
index 1e3f1d4..528ffd1 100644
--- a/st.1
+++ b/st.1
_AT_@ -87,6 +87,13 @@ defines the window title (default 'st').
 .BI \-t " title"
 defines the window title (default 'st').
 .TP
+.BI \-s
+synchronize clipboards. If
+.I primary(selection)
+is pasted, then
+.I clipboard
+will have some data.
+.TP
 .BI \-w " windowid"
 embeds st within the window identified by
 .I windowid
_AT_@ -176,4 +183,3 @@ See the LICENSE file for the terms of redistribution.
 .BR stty (1)
 .SH BUGS
 See the TODO file in the distribution.
-
diff --git a/st.c b/st.c
index 2594c65..07b1d79 100644
--- a/st.c
+++ b/st.c
_AT_@ -262,6 +262,7 @@ typedef struct {
 	XSetWindowAttributes attrs;
 	int scr;
 	int isfixed; /* is fixed geometry? */
+	int issynchronizeclipboards;
 	int l, t; /* left and top offset */
 	int gm; /* geometry mask */
 	int tw, th; /* tty width and height */
_AT_@ -1263,6 +1264,9 @@ xsetsel(char *str, Time t)
 	XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t);
 	if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win)
 		selclear(0);
+
+	if (xw.issynchronizeclipboards)
+		clipcopy(NULL);
 }
 
 void
_AT_@ -4338,7 +4342,7 @@ main(int argc, char *argv[])
 	uint cols = 80, rows = 24;
 
 	xw.l = xw.t = 0;
-	xw.isfixed = False;
+	xw.isfixed = xw.issynchronizeclipboards = False;
 	xw.cursor = cursorshape;
 
 	ARGBEGIN {
_AT_@ -4371,6 +4375,9 @@ main(int argc, char *argv[])
 	case 'n':
 		opt_name = EARGF(usage());
 		break;
+	case 's':
+		xw.issynchronizeclipboards = 1;
+		break;
 	case 't':
 	case 'T':
 		opt_title = EARGF(usage());
_AT_@ -4401,4 +4408,3 @@ run:
 
 	return 0;
 }
-
-- 
2.9.0
Received on Sat Jul 09 2016 - 20:28:27 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 09 2016 - 20:36:13 CEST