shithub: orca

Download patch

ref: e153011a788a20522317155016d2bdccc85760eb
parent: ca65bd1678c46df10637aa2c9d961108363552e0
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Feb 24 18:21:49 EST 2020

plan9: add "write" command and keep only space and tab as arg separator since ";" and ":" are valid glyphs and someone might actually want to insert them as part of the command

--- a/orca.man
+++ b/orca.man
@@ -237,9 +237,15 @@
 .TP
 .B midi PATH
 Set MIDI output path.
+.TP
 .B print
 Print selected rectangle to
 .IR stdout .
+.TP
+.B write TEXT [X] [Y]
+Writes the text at the cursor position or at
+.I X,Y
+if specified.
 .PP
 .I Orca
 treats
--- a/plan9.c
+++ b/plan9.c
@@ -447,7 +447,7 @@
 command(char *s, void (*snapshot)(void))
 {
 	char tmp[256];
-	char *a;
+	char *a, *b;
 	int x, y;
 
 	snprint(tmp, sizeof(tmp), "%s", s);
@@ -467,7 +467,7 @@
 		return;
 	}
 
-	if ((a = strchr(s, ':')) != nil || (a = strchr(s, ' ')) != nil)
+	if ((a = strpbrk(s, " \t")) != nil)
 		*a++ = 0;
 
 	if (s[0] == 'p' && s[1] == 'l') /* play */
@@ -510,6 +510,19 @@
 			netdial(nil, a);
 		else if (s[0] == 'm' && s[1] == 'i') /* midi */
 			midiopen(a);
+		else if (s[0] == 'w' && s[1] == 'r') { /* write:abcd;13;14 */
+			b = a;
+			x = cur.x;
+			y = cur.y;
+			if ((a = strpbrk(b, " \t")) != nil) {
+				*a++ = 0;
+				x = atoi(a);
+				if ((a = strpbrk(a, " \t")) != nil)
+					y = atoi(++a);
+			}
+			for (; *b != 0; x++, b++)
+				fieldset(x, y, *b);
+		}
 
 		/* FIXME color, find, select, inject, write, time */
 	} else if (strcmp(s, "undo") == 0) {