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
157to the command, and the other way around when it comes to command's157to the command, and the other way around when it comes to command's
158output.158output.
159.TP159.TP
160.B <cmd arg...
161Execute a shell command and paste its output into the grid. Dots are
162replaced with spaces.
163.TP
164.B >cmd arg...
165Pipe the selected text to a shell command. Dots are replaced with spaces.
166.TP
160.B play167.B play
161Resume.168Resume.
162.TP169.TP
plan9.c+7−6
@@ -197,7 +197,7 @@ selpasteb(Biobuf *b) · 196 unmodified lines
197 cols = MIN(n, field.width-sel.min.x);197 cols = MIN(n, field.width-sel.min.x);
198 if (sel.min.y+rows < field.height) {198 if (sel.min.y+rows < field.height) {
199 for (i = 0; i < n; i++)199 for (i = 0; i < n; i++)
200 if (s[i] == ' ')200 if (!orca_is_valid_glyph(s[i]))
201 s[i] = '.';201 s[i] = '.';
202 memmove(&field.buffer[sel.min.x + field.width*(sel.min.y+rows)], s, MIN(n, field.width-sel.min.x));202 memmove(&field.buffer[sel.min.x + field.width*(sel.min.y+rows)], s, MIN(n, field.width-sel.min.x));
203 rows++;203 rows++;
@@ -234,7 +234,7 @@ shellpipe(char *s) · 30 unmodified lines
234 int x, y, p[4];234 int x, y, p[4];
235 Glyph g;235 Glyph g;
236 236
237 shellcmd = s;237 shellcmd = s+1;
238 pipe(p);238 pipe(p);
239 pipe(p+2);239 pipe(p+2);
240 procrfork(runshell, p, 4096, RFFDG);240 procrfork(runshell, p, 4096, RFFDG);
@@ -242,7 +242,7 @@ shellpipe(char *s) · 1 unmodified line
242 close(p[3]);242 close(p[3]);
243 out = Bfdopen(p[1], OWRITE);243 out = Bfdopen(p[1], OWRITE);
244 in = Bfdopen(p[2], OREAD);244 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++) {
246 for (x = sel.min.x; x <= sel.max.x; x++) {246 for (x = sel.min.x; x <= sel.max.x; x++) {
247 if ((g = fieldget(x, y)) == '.')247 if ((g = fieldget(x, y)) == '.')
248 g = ' ';248 g = ' ';
@@ -251,7 +251,8 @@ shellpipe(char *s) · 2 unmodified lines
251 Bputc(out, '\n');251 Bputc(out, '\n');
252 }252 }
253 Bterm(out);253 Bterm(out);
254 selpasteb(in);254 if (*s != '>')
255 selpasteb(in);
255 Bterm(in);256 Bterm(in);
256}257}
257 258
@@ -267,8 +268,8 @@ command(char *s) · 9 unmodified lines
267 s++;268 s++;
268 }269 }
269 270
270 if (s[0] == '|') {271 if (s[0] == '|' || s[0] == '>' || s[0] == '<') {
271 shellpipe(s+1);272 shellpipe(s);
272 return;273 return;
273 }274 }
274 275

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