New explode/join registers
This commit is contained in:
parent
3bce3dab79
commit
6e0d3bb9e0
44
src/modal.c
44
src/modal.c
|
@ -55,32 +55,31 @@ put_reg(char r)
|
|||
}
|
||||
ss = walk(s);
|
||||
if(r == '*') {
|
||||
if(*s == '(') { /* special implode */
|
||||
while(s < ss && (c = *s++))
|
||||
if(!spacer(c)) *dst_++ = c;
|
||||
} else { /* special explode */
|
||||
int i, depth = 0;
|
||||
int i, depth = 0;
|
||||
if(*s == '(') { /* special explode tuple */
|
||||
s++;
|
||||
while(s < ss) {
|
||||
while((c = *s) && !spacer(c))
|
||||
*dst_++ = c, s++;
|
||||
*dst_++ = ' ';
|
||||
*dst_++ = '(', s++, depth++;
|
||||
}
|
||||
} else { /* special explode token */
|
||||
while((c = *s++) && !spacer(c))
|
||||
*dst_++ = c, *dst_++ = ' ', *dst_++ = '(', depth++;
|
||||
for(i = 0; i < depth; i++)
|
||||
*dst_++ = ')';
|
||||
}
|
||||
} else if(r == '.') { /* special unpack */
|
||||
if(*s == '(')
|
||||
s++, --ss;
|
||||
while(s < ss) *dst_++ = *s++;
|
||||
} else if(r == '^') { /* special align */
|
||||
int i, depth = 0;
|
||||
s++;
|
||||
while(s < ss) {
|
||||
*dst_++ = '(';
|
||||
while((c = *s) && !spacer(c))
|
||||
*dst_++ = c, s++;
|
||||
if(s < ss - 1) *dst_++ = ' ';
|
||||
s++, depth++;
|
||||
}
|
||||
for(i = 0; i < depth; i++)
|
||||
*dst_++ = ')';
|
||||
} else if(r == '.') { /* special unpack */
|
||||
if(*s == '(') s++, --ss;
|
||||
while(s < ss) *dst_++ = *s++;
|
||||
} else if(r == '^') { /* special join */
|
||||
if(*s == '(') s++, --ss;
|
||||
while(s < ss && (c = *s++))
|
||||
if(!spacer(c)) *dst_++ = c;
|
||||
} else if(r == '~') { /* special stdin */
|
||||
while(fread(&c, 1, 1, stdin) && c >= ' ')
|
||||
*dst_++ = c;
|
||||
} else if(r == ':') { /* special stdout */
|
||||
if(*s == '(') s++, --ss;
|
||||
while(s < ss) {
|
||||
|
@ -94,9 +93,6 @@ put_reg(char r)
|
|||
} else
|
||||
putc(c, stdout);
|
||||
}
|
||||
} else if(r == '~') { /* special stdin */
|
||||
while(fread(&c, 1, 1, stdin) && c >= ' ')
|
||||
*dst_++ = c;
|
||||
} else
|
||||
while(s < ss) *dst_++ = *s++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue