shithub: pplay

Download patch

ref: 7ae4c9dfd54b610ba916dce3f351834573265849
parent: 9dc9a4c9b250bbd2317f46f81ae2e8e42b3f3d2b
author: qwx <[email protected]>
date: Sat Jan 7 20:30:44 EST 2023

add (s)how command: spawn new pplay with contents of dot

--- a/chunk.c
+++ b/chunk.c
@@ -123,7 +123,7 @@
 	return nc;
 }
 Chunk *
-replicate(Chunk *left, Chunk *right)
+clone(Chunk *left, Chunk *right)
 {
 	Chunk *cl, *c, *nc;
 
--- a/cmd.c
+++ b/cmd.c
@@ -149,7 +149,7 @@
 		werrstr("paste: no buffer");
 		return -1;
 	}
-	c = replicate(c, c->left);
+	c = clone(c, c->left);
 	if(dot.from == 0 && dot.to == totalsz)
 		return insert(s, c);
 	else
@@ -172,7 +172,7 @@
 
 	dprint(hold, "cmd/copy %Δ\n", &dot);
 	splitrange(dot.from, dot.to, &left, &right);
-	snarf(replicate(left, right));
+	snarf(clone(left, right));
 	return 0;
 }
 
@@ -188,7 +188,7 @@
 	dprint(nil, "cmd/cut %Δ\n", &dot);
 	cutrange(dot.from, dot.to, &latch);
 	dprint(latch, "latched\n");
-	snarf(replicate(latch, latch->left));
+	snarf(clone(latch, latch->left));
 	pushop(OPdel, dot.from, dot.from+chunklen(latch)-1, latch);
 	setdot(&dot, nil);
 	return 1;
@@ -364,6 +364,15 @@
 }
 
 static int
+replicate(char *)
+{
+	static char u[256];
+
+	snprint(u, sizeof u, "<[3=0] window -m %s /fd/3", argv0);
+	return pipeto(u);
+}
+
+static int
 readfrom(char *s)
 {
 	int fd;
@@ -429,6 +438,7 @@
 	case 'p': x = paste(s, nil); break;
 	case 'q': threadexitsall(nil);
 	case 'r': x = readfrom(s); break;
+	case 's': x = replicate(s); break;
 //	case 'U': x = unpop(s); break;
 	case 'u': x = popop(s); break;
 	case 'w': x = writeto(s); break;
--- a/fns.h
+++ b/fns.h
@@ -5,7 +5,7 @@
 void	recalcsize(void);
 void	paranoia(int);
 void	setdot(Dot*, Chunk*);
-Chunk*	replicate(Chunk*, Chunk*);
+Chunk*	clone(Chunk*, Chunk*);
 int	splitrange(usize, usize, Chunk**, Chunk**);
 void	graphfrom(Chunk*);
 Chunk*	inserton(usize, usize, Chunk*, Chunk**);
--- a/pplay.man
+++ b/pplay.man
@@ -164,6 +164,11 @@
 .BI r\  file
 ∗ Read file into dot or at the cursor
 .TP
+.B s
+Show dot by piping it to a new
+.IR pplay (1)
+instance
+.TP
 .B u
 Undo an edit and dot change
 .TP