ref: 324ef5bee41f0c7ce6824b5feab2bea4bd2fd983
parent: 370b8838b4b63a5621e5b4756dcb65f1c14542fe
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Mar 8 20:40:55 EDT 2020
plan9: support plumbing to inject files
--- a/orca.man
+++ b/orca.man
@@ -276,5 +276,17 @@
telnet tcp!127.0.0.1!49160
.EE
.PP
+.SH PLUMBING
+Orca supports injecting files at the current cursor position by
+plumbing. Add this to your plumbing rules to get it working:
+.EX
+type is text
+data matches '[a-zA-Z¡-0-9_\-.,/]+'
+data matches '([a-zA-Z¡-0-9_\-.,/]+)\.orca'
+arg isfile $0
+plumb to orca
+plumb start window games/orca $file
+.EE
+.PP
.SH SOURCE
https://github.com/hundredrabbits/Orca
--- a/plan9.c
+++ b/plan9.c
@@ -7,6 +7,7 @@
#include <mouse.h>
#include <keyboard.h>
#include <thread.h>
+#include <plumb.h>
#define MIN(x,y) ((x)<=(y)?(x):(y))
#define MAX(x,y) ((x)>=(y)?(x):(y))
@@ -1117,6 +1118,23 @@
}
static void
+plumbthread(void *)
+{
+ int f;
+ Plumbmsg *m;
+
+ threadsetname("plumb");
+ if ((f = plumbopen("orca", OREAD)) >= 0) {
+ while ((m = plumbrecv(f)) != nil) {
+ inject(m->data);
+ plumbfree(m);
+ }
+ }
+
+ threadexits(nil);
+}
+
+static void
kbdproc(void *cchan)
{
char buf[128], buf2[128], *s;
@@ -1367,6 +1385,8 @@
midiopen(nil);
snaps = calloc(maxsnaps, sizeof(Snap));
+
+ proccreate(plumbthread, nil, mainstacksize);
for (;;) {
redraw(complete);