shithub: castor9

Download patch

ref: be3ff72d76d6c529e45d138eca51fb0a3380119e
parent: 6a24e215725d72e1c24d880809f5ea3454d7a6f8
author: fulton@fulton.software <fulton@fulton.software>
date: Fri Mar 26 10:26:03 EDT 2021

From b9f54564d6fee7515b7a4981f2eef6c121bf7e0d
From: Fulton Browne <git@fulton.software>
Date: Fri, 26 Mar 2021 21:23:17 +0000
Subject: [PATCH] Added plumbto gemini listener

With code adapted from phil9's gopher, castor9 can now recive messages from the plumber via plumbto gemini.

--- a/castor.c
+++ b/castor.c
@@ -801,7 +801,8 @@
 {
 	Event e;
 	Url *url;
-	
+	enum { Eplumb = 128 };
+	Plumbmsg *pm;
 	if(argc == 2)
 		if(strbeg(argv[1], "gemini://") != 0){
 			url = urlparse(nil, smprint("gemini://%s", argv[1]));
@@ -826,8 +827,16 @@
 	mkpanels();
 	geminiget(url);
 	eresized(0);
+	eplumb(Eplumb, "gemini");
 	for(;;){
 		switch(event(&e)){
+		case Eplumb:
+			pm = e.v;
+			if(pm->ndata > 0){
+				geminiget(urlparse(nil, pm->data));
+			}
+			plumbfree(pm);
+			break;
 		case Ekeyboard:
 			switch(e.kbdc){
 			default: