History

plan9: add > and < pipe-style commands

Sigrid Haflínudóttir committed 6 years ago

Commit 99dcd951 parent a79389e2 files · +14 −6Browse files

Unified · Split

2 files
  1. orca.man +7 −0
  2. plan9.c +7 −6
orca.man+7−0
@@ -157,6 +157,13 @@ into the grid. Dots are replaced with spaces before feeding the input · 156 unmodified lines
157157 to the command, and the other way around when it comes to command's
158158 output.
159159 .TP
160+.B <cmd arg...
161+Execute a shell command and paste its output into the grid. Dots are
162+replaced with spaces.
163+.TP
164+.B >cmd arg...
165+Pipe the selected text to a shell command. Dots are replaced with spaces.
166+.TP
160167 .B play
161168 Resume.
162169 .TP
plan9.c+7−6
@@ -197,7 +197,7 @@ selpasteb(Biobuf *b) · 196 unmodified lines
197197 cols = MIN(n, field.width-sel.min.x);
198198 if (sel.min.y+rows < field.height) {
199199 for (i = 0; i < n; i++)
200− if (s[i] == ' ')
200+ if (!orca_is_valid_glyph(s[i]))
201201 s[i] = '.';
202202 memmove(&field.buffer[sel.min.x + field.width*(sel.min.y+rows)], s, MIN(n, field.width-sel.min.x));
203203 rows++;
@@ -234,7 +234,7 @@ shellpipe(char *s) · 30 unmodified lines
234234 int x, y, p[4];
235235 Glyph g;
236236
237− shellcmd = s;
237+ shellcmd = s+1;
238238 pipe(p);
239239 pipe(p+2);
240240 procrfork(runshell, p, 4096, RFFDG);
@@ -242,7 +242,7 @@ shellpipe(char *s) · 1 unmodified line
242242 close(p[3]);
243243 out = Bfdopen(p[1], OWRITE);
244244 in = Bfdopen(p[2], OREAD);
245− for (y = sel.min.y; y <= sel.max.y; y++) {
245+ for (y = sel.min.y; *s != '<' && y <= sel.max.y; y++) {
246246 for (x = sel.min.x; x <= sel.max.x; x++) {
247247 if ((g = fieldget(x, y)) == '.')
248248 g = ' ';
@@ -251,7 +251,8 @@ shellpipe(char *s) · 2 unmodified lines
251251 Bputc(out, '\n');
252252 }
253253 Bterm(out);
254− selpasteb(in);
254+ if (*s != '>')
255+ selpasteb(in);
255256 Bterm(in);
256257 }
257258
@@ -267,8 +268,8 @@ command(char *s) · 9 unmodified lines
267268 s++;
268269 }
269270
270− if (s[0] == '|') {
271− shellpipe(s+1);
271+ if (s[0] == '|' || s[0] == '>' || s[0] == '<') {
272+ shellpipe(s);
272273 return;
273274 }
274275

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