History

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

Sigrid Haflínudóttir committed 6 years ago

Commit 27486da1 parent 85497621 file · +11 −2Browse files

Unified · Split

plan9.c+11−2
@@ -77,6 +77,7 @@ static int rulerstyle = Sfancy, dotstyle = Sfancy; · 76 unmodified lines
7777
7878 static char *ip, *udpport;
7979 static int udp = -1;
80+static int nl = 0;
8081
8182 static char *midipath;
8283 static int midi = -1;
@@ -838,7 +839,9 @@ command(char *s, void (*snapshot)(void)) · 755 unmodified lines
838839 } else if (argc > 1) {
839840 x = atoi(argv[1]);
840841
841− if (s[0] == 'b' && s[1] == 'p') /* bpm */
842+ if (s[0] == 'n' && s[1] == 'l' && s[2] == 0) /* nl */
843+ nl = x;
844+ else if (s[0] == 'b' && s[1] == 'p') /* bpm */
842845 apm = bpm = MAX(1, x);
843846 else if (s[0] == 'a' && s[1] == 'p') /* apm */
844847 apm = MAX(1, x);
@@ -951,7 +954,13 @@ process(Oevent_list *events) · 106 unmodified lines
951954
952955 if (t == Oevent_type_udp_string && udp >= 0) {
953956 Oevent_udp_string *u = &e->udp_string;
954− write(udp, u->chars, u->count); /* FIXME show errors */
957+ if (u->count < sizeof(tmp)-1) {
958+ memmove(tmp, u->chars, u->count);
959+ if (nl)
960+ tmp[u->count++] = '\n';
961+ tmp[u->count] = 0;
962+ write(udp, tmp, u->count); /* FIXME show errors */
963+ }
955964 continue;
956965 } else if (t == Oevent_type_cmd_string) {
957966 Oevent_cmd_string *c = &e->cmd_string;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t