From 58ece9f9a131941750a8d334e09d3c2aae926140 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 6 May 2020 12:19:36 -0400 Subject: [PATCH] editor: implement I command Also, made LIST properly handle full 64-chars lines not ending with a null or CR. Previously, such a line would be accompanied by its following line, duplicating that line's output. --- blk/101 | 2 +- blk/102 | 2 +- blk/105 | 2 +- blk/108 | 15 +++++++++++++++ blk/456 | 6 ++++-- emul/forth.bin | Bin 5702 -> 5768 bytes 6 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 blk/108 diff --git a/blk/101 b/blk/101 index 2089d4b..4890ddf 100644 --- a/blk/101 +++ b/blk/101 @@ -2,7 +2,7 @@ T ( n -- ): select line n for editing. P xxx: put typed line on selected line. U xxx: insert typed line on selected line. F xxx: find typed string in block. - +I xxx: insert typed string at cursor diff --git a/blk/102 b/blk/102 index 210a603..26ad3bc 100644 --- a/blk/102 +++ b/blk/102 @@ -1,5 +1,5 @@ 50 LOAD+ ( B152, extras ) -1 5 LOADR+ +1 6 LOADR+ : BROWSE 0 ACC ! L diff --git a/blk/105 b/blk/105 index c62e3c5..2a3edab 100644 --- a/blk/105 +++ b/blk/105 @@ -1,5 +1,5 @@ : _type ( buf -- ) - C< DUP 0xd = IF DROP EXIT THEN OVER DUP _zbuf ( c a ) + C< DUP 0xd = IF 2DROP EXIT THEN OVER DUP _zbuf ( c a ) BEGIN ( c a ) C!+ C< SWAP OVER 0x0d = UNTIL ( c a ) C! ; diff --git a/blk/108 b/blk/108 new file mode 100644 index 0000000..1c7dd55 --- /dev/null +++ b/blk/108 @@ -0,0 +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 ) + 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 ) + THEN + SWAP DROP IBUF EDPOS @ _cpos ROT MOVE +; diff --git a/blk/456 b/blk/456 index 7b48c02..f34b504 100644 --- a/blk/456 +++ b/blk/456 @@ -1,10 +1,12 @@ : .2 DUP 10 < IF SPC THEN . ; - +: EOL? ( c -- f ) DUP 0xd = SWAP NOT OR ; : LIST BLK@ 16 0 DO I 1+ .2 SPC - 64 I * BLK( + (print) + 64 I * BLK( + DUP 64 + SWAP DO + I C@ DUP EOL? IF DROP LEAVE ELSE EMIT THEN + LOOP NL LOOP ; diff --git a/emul/forth.bin b/emul/forth.bin index 6c565b3223a3ee2dafbd952a331ed7f0e57c8361..61a7629c69ead3b5ed3dd252a0b52bbe69000160 100644 GIT binary patch delta 156 zcmX@6)1k|GcqYT)T?`Bi9UD14MPyz5eeA^U z94?}01CnuIn9j7FaWQi;vp(}I#z>KL1}=uxj8k}n8CV#$@cHwmGd%l$j9Hv%8$XD> z3(R(6h>x1wB@)PZZt@+G6vkJR9Yv*pWQ?dfW8dT!(SEKAqF%!PnN%2f#3sv%X#xPi CpDSzt delta 111 zcmV-#0FeKPEygSf!