[wiki] [sites] fix osc52 patch || Markus Teich

From: <git_AT_suckless.org>
Date: Tue, 07 Feb 2017 12:43:10 +0100

commit f0746d27590fe00b3ef55ac29ccfa47f61f3cdf9
Author: Markus Teich <markus.teich_AT_stusta.mhn.de>
Date: Tue Feb 7 12:43:09 2017 +0100

    fix osc52 patch

diff --git a/st.suckless.org/patches/osc52.diff b/st.suckless.org/patches/osc52.diff
deleted file mode 100644
index e07a7b0..0000000
--- a/st.suckless.org/patches/osc52.diff
+++ /dev/null
_AT_@ -1,96 +0,0 @@
-diff --git a/base64dec.c b/base64dec.c
-new file mode 100644
-index 0000000..3f75aab
---- /dev/null
-+++ b/base64dec.c
-_AT_@ -0,0 +1,42 @@
-+/*taken from libulz with permission*/
-+
-+static const char base64_tbl[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-+
-+inline int chrpos(int c) {
-+ int i = 0;
-+ for(;i<64;i++) if(base64_tbl[i] == c) return i;
-+ return -1;
-+}
-+static size_t base64dec(void* dst, const char* src, size_t dst_len) {
-+ const char* s = src;
-+ unsigned char *d = dst;
-+ size_t l = dst_len, o = 0;
-+ int n = 0, cnt = 0, skip = 0;
-+ if(l) for(;;) {
-+ int p;
-+ if(*s == '=') {
-+ skip++;
-+ if(skip > 2) return 0;
-+ p = 0;
-+ } else if (!*s) {
-+ if(cnt % 4 != 0 || !l) return 0;
-+ *d++ = 0;
-+ return o;
-+ } else if(skip) {
-+ return 0;
-+ } else if((p = chrpos(*s)) == -1) return 0;
-+ n = (n << 6) | p;
-+ cnt++;
-+ if(cnt % 4 == 0) {
-+ if(l < 3) return 0;
-+ *d++ = n >> 16;
-+ *d++ = n >> 8 & 0xff;
-+ *d++ = n & 0xff;
-+ l -= 3;
-+ o += 3-skip;
-+ n = 0;
-+ }
-+ s++;
-+ }
-+ return 0;
-+}
-diff --git a/st.c b/st.c
-index fbcd9e0..54cceeb 100644
---- a/st.c
-+++ b/st.c
-_AT_@ -32,7 +32,7 @@
- #include <wchar.h>
-
- #include "arg.h"
--
-+#include "base64dec.c"
- char *argv0;
- 
- #define Glyph Glyph_
-_AT_@ -2533,11 +2533,21 @@ strhandle(void)
- 			if (narg > 1)
- 				xsettitle(strescseq.args[1]);
- 			return;
--		case 4: /* color set */
-+		case 52:/*set tmux clipboard*/
-+			if (narg > 2){
-+				char *src=strescseq.args[2];
-+				size_t l = (strlen(src)/4)*3;
-+				char *buf=xmalloc(l+1);
-+				base64dec(buf, src, l);
-+				xsetsel(buf, CurrentTime);
-+			}
-+			return;
-+			case 4: /* color set */
- 			if (narg < 3)
- 				break;
- 			p = strescseq.args[2];
- 			/* FALLTHROUGH */
-+
- 		case 104: /* color reset, here p = NULL */
- 			j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
- 			if (xsetcolorname(j, p)) {
-diff --git a/st.info b/st.info
-index 13cc8eb..0b928af 100644
---- a/st.info
-+++ b/st.info
-_AT_@ -189,6 +189,7 @@ st| simpleterm,
- 	Se,
- 	Ss,
- 	Tc,
-+	Ms=\E]52;%p1%s;%p2%s,
- 
- st-256color| simpleterm with 256 colors,
- 	use=st,
diff --git a/st.suckless.org/patches/osc52.md b/st.suckless.org/patches/osc52.md
index d83fc92..671bab3 100644
--- a/st.suckless.org/patches/osc52.md
+++ b/st.suckless.org/patches/osc52.md
_AT_@ -4,16 +4,19 @@ OSC-52 tmux clipboard
 Description
 -----------
 
-This patch adds OSC 52 control sequence support to st to support the syncing of tmux's clipboard to the X PRIMARY selection..
+This patch adds OSC 52 control sequence support to st to support the syncing of
+tmux's clipboard to the X PRIMARY selection..
 
 Notes
 -----
 
-For remote tmux instances, you must update the terminfo with the included terminfo here. 
+For remote tmux instances, you must update the terminfo with the included
+terminfo here.
+
 Download
 --------
 
- * [osc52.diff](osc52.diff)
+ * [st-osc52-20170125-c63a87c.diff](st-osc52-20170125-c63a87c.diff)
 
 Authors
 -------
diff --git a/st.suckless.org/patches/st-osc52-20170125-c63a87c.diff b/st.suckless.org/patches/st-osc52-20170125-c63a87c.diff
new file mode 100644
index 0000000..e07a7b0
--- /dev/null
+++ b/st.suckless.org/patches/st-osc52-20170125-c63a87c.diff
_AT_@ -0,0 +1,96 @@
+diff --git a/base64dec.c b/base64dec.c
+new file mode 100644
+index 0000000..3f75aab
+--- /dev/null
++++ b/base64dec.c
+_AT_@ -0,0 +1,42 @@
++/*taken from libulz with permission*/
++
++static const char base64_tbl[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
++
++inline int chrpos(int c) {
++	int i = 0;
++	for(;i<64;i++) if(base64_tbl[i] == c) return i;
++	return -1;
++}
++static size_t base64dec(void* dst, const char* src, size_t dst_len) {
++	const char* s = src;
++	unsigned char *d = dst;
++	size_t l = dst_len, o = 0;
++	int n = 0, cnt = 0, skip = 0;
++	if(l) for(;;) {
++		int p;
++		if(*s == '=') {
++			skip++;
++			if(skip > 2) return 0;
++			p = 0;
++		} else if (!*s) {
++			if(cnt % 4 != 0 || !l) return 0;
++			*d++ = 0;
++			return o;
++		} else if(skip) {
++			return 0;
++		} else if((p = chrpos(*s)) == -1) return 0;
++		n = (n << 6) | p;
++		cnt++;
++		if(cnt % 4 == 0) {
++			if(l < 3) return 0;
++			*d++ = n >> 16;
++			*d++ = n >> 8 & 0xff;
++			*d++ = n & 0xff;
++			l -= 3;
++			o += 3-skip;
++			n = 0;
++		}
++		s++;
++	}
++	return 0;
++}
+diff --git a/st.c b/st.c
+index fbcd9e0..54cceeb 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -32,7 +32,7 @@
+ #include <wchar.h>
+ 
+ #include "arg.h"
+-
++#include "base64dec.c"
+ char *argv0;
+ 
+ #define Glyph Glyph_
+_AT_@ -2533,11 +2533,21 @@ strhandle(void)
+ 			if (narg > 1)
+ 				xsettitle(strescseq.args[1]);
+ 			return;
+-		case 4: /* color set */
++		case 52:/*set tmux clipboard*/
++			if (narg > 2){
++				char *src=strescseq.args[2];
++				size_t l = (strlen(src)/4)*3;
++				char *buf=xmalloc(l+1);
++				base64dec(buf, src, l);
++				xsetsel(buf, CurrentTime);
++			}
++			return;
++			case 4: /* color set */
+ 			if (narg < 3)
+ 				break;
+ 			p = strescseq.args[2];
+ 			/* FALLTHROUGH */
++
+ 		case 104: /* color reset, here p = NULL */
+ 			j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
+ 			if (xsetcolorname(j, p)) {
+diff --git a/st.info b/st.info
+index 13cc8eb..0b928af 100644
+--- a/st.info
++++ b/st.info
+_AT_@ -189,6 +189,7 @@ st| simpleterm,
+ 	Se,
+ 	Ss,
+ 	Tc,
++	Ms=\E]52;%p1%s;%p2%s,
+ 
+ st-256color| simpleterm with 256 colors,
+ 	use=st,
Received on Tue Feb 07 2017 - 12:43:10 CET

This archive was generated by hypermail 2.3.0 : Tue Feb 07 2017 - 12:48:22 CET