shithub: orca

Download patch

ref: 27486da4138fbdd27873193f75e793b65d158d3b
parent: 85497628f1036f7d26057fa38e63afb941119d38
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Mar 19 20:53:16 EDT 2020

plan9: add "nl" command to append a newline to every UDP message (for stuff like |[3]....)

--- a/plan9.c
+++ b/plan9.c
@@ -77,6 +77,7 @@
 
 static char *ip, *udpport;
 static int udp = -1;
+static int nl = 0;
 
 static char *midipath;
 static int midi = -1;
@@ -838,7 +839,9 @@
 	} else if (argc > 1) {
 		x = atoi(argv[1]);
 
-		if (s[0] == 'b' && s[1] == 'p') /* bpm */
+		if (s[0] == 'n' && s[1] == 'l' && s[2] == 0) /* nl */
+			nl = x;
+		else if (s[0] == 'b' && s[1] == 'p') /* bpm */
 			apm = bpm = MAX(1, x);
 		else if (s[0] == 'a' && s[1] == 'p') /* apm */
 			apm = MAX(1, x);
@@ -951,7 +954,13 @@
 
 		if (t == Oevent_type_udp_string && udp >= 0) {
 			Oevent_udp_string *u = &e->udp_string;
-			write(udp, u->chars, u->count); /* FIXME show errors */
+			if (u->count < sizeof(tmp)-1) {
+				memmove(tmp, u->chars, u->count);
+				if (nl)
+					tmp[u->count++] = '\n';
+				tmp[u->count] = 0;
+				write(udp, tmp, u->count); /* FIXME show errors */
+			}
 			continue;
 		} else if (t == Oevent_type_cmd_string) {
 			Oevent_cmd_string *c = &e->cmd_string;