editor: simplify I with the use of MOVE-

Also, delay the shadowing of DO..LOOP's I for as long as possible.
This commit is contained in:
Virgil Dupras 2020-05-06 21:10:27 -04:00
parent eaeb138a0c
commit feb0411530
2 changed files with 11 additions and 12 deletions

View File

@ -12,5 +12,5 @@
ENDCASE
AGAIN
;
( I masks DO..LOOP's I. Do it as late as possible. )
: I _I ;

19
blk/108
View File

@ -1,16 +1,15 @@
: _ilen ( length of str in IBUF )
IBUF BEGIN C@+ EOL? UNTIL IBUF - 1- ;
: I
IBUF _type EDPOS @ 64 /MOD ( cno lno )
1+ 64 * _cpos ( cno next-line-ptr )
SWAP 63 -^ _ilen ( nlp nb-of-chars-to-move ilen )
: _I
IBUF _type EDPOS @ 64 MOD ( cno )
63 -^ _ilen ( rbuffsize ilen )
2DUP > IF
SWAP OVER - 1+ ( nlp ilen nbc ) 0 DO ( a ilen )
SWAP 1- 2DUP -^ ( ilen a-1 a-ilen-1 ) C@ OVER C!
SWAP ( a ilen )
LOOP
ELSE DROP ( ilen becomes nbc )
SWAP OVER - ( ilen chars-to-move )
SWAP EDPOS @ _cpos 2DUP + ( ctm ilen a a+ilen )
3 PICK MOVE- ( ctm ilen )
SWAP DROP ( ilen )
ELSE DROP ( ilen becomes rbuffsize )
THEN
SWAP DROP DUP IBUF EDPOS @ _cpos ROT MOVE ( ilen )
DUP IBUF EDPOS @ _cpos ROT MOVE ( ilen )
EDPOS +! EDPOS @ 64 / _pln
;