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
77 77
78static char *ip, *udpport;78static char *ip, *udpport;
79static int udp = -1;79static int udp = -1;
80static int nl = 0;
80 81
81static char *midipath;82static char *midipath;
82static int midi = -1;83static int midi = -1;
@@ -838,7 +839,9 @@ command(char *s, void (*snapshot)(void)) · 755 unmodified lines
838 } else if (argc > 1) {839 } else if (argc > 1) {
839 x = atoi(argv[1]);840 x = atoi(argv[1]);
840 841
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 */
842 apm = bpm = MAX(1, x);845 apm = bpm = MAX(1, x);
843 else if (s[0] == 'a' && s[1] == 'p') /* apm */846 else if (s[0] == 'a' && s[1] == 'p') /* apm */
844 apm = MAX(1, x);847 apm = MAX(1, x);
@@ -951,7 +954,13 @@ process(Oevent_list *events) · 106 unmodified lines
951 954
952 if (t == Oevent_type_udp_string && udp >= 0) {955 if (t == Oevent_type_udp_string && udp >= 0) {
953 Oevent_udp_string *u = &e->udp_string;956 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 }
955 continue;964 continue;
956 } else if (t == Oevent_type_cmd_string) {965 } else if (t == Oevent_type_cmd_string) {
957 Oevent_cmd_string *c = &e->cmd_string;966 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