From 4d893d90fc13f1e096faba32120635ff8ba05f5c Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 8 Jun 2020 21:23:23 -0400 Subject: [PATCH] VE: Improve I and F buffer typing Previously, it would keep the old buffer displayed why typing over it. I had kept it thus because I didn't want to erase the buffer right away because the behavior is that when we type nothing, we keep the buffer as-is and repeat the action. Now, the behavior of I and F is much better. It keeps the buffer displayed until the first non-return keystroke and then erases it. Also, fixed PSP leak in _type and fixed PSP overuse in successful _F (they balanced out). --- blk/105 | 6 ++---- blk/107 | 12 ++++++------ blk/108 | 6 +++--- blk/127 | 5 +++++ blk/128 | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/blk/105 b/blk/105 index 01ff871..176a01b 100644 --- a/blk/105 +++ b/blk/105 @@ -1,8 +1,6 @@ : _type ( buf -- ) - C< DUP 0xd = IF 2DROP EXIT THEN OVER DUP _zbuf ( c a ) - BEGIN ( c a ) - C!+ C< SWAP - OVER 0x0d = UNTIL ( c a ) C! ; + C< DUP 0xd = IF 2DROP EXIT THEN SWAP DUP _zbuf ( c a ) + BEGIN ( c a ) C!+ C< TUCK 0x0d = UNTIL ( c a ) C! ; ( user-facing lines are 1-based ) : T 1- DUP 64 * EDPOS ! _pln ; : P IBUF _type IBUF EDPOS @ _cpos 64 MOVE BLK!! ; diff --git a/blk/107 b/blk/107 index 9cebddc..c05a925 100644 --- a/blk/107 +++ b/blk/107 @@ -1,10 +1,10 @@ -: _F ( F without _pln. used in VE ) - FBUF _type FBUF EDPOS @ _cpos ( a1 a2 ) +: _F ( F without _type and _pln. used in VE ) + FBUF EDPOS @ _cpos ( a1 a2 ) BEGIN C@+ ROT ( a2+1 c2 a1 ) C@+ ROT ( a2+1 a1+1 c1 c2 ) - = NOT IF DROP FBUF THEN + = NOT IF DROP FBUF THEN ( a2 a1 ) TUCK C@ 0xd = ( a1 a2 f1 ) OVER BLK) = OR ( a1 a2 f1|f2 ) - UNTIL - DUP BLK) < IF BLK( - FBUF + -^ EDPOS ! THEN DROP ; -: F _F EDPOS @ 64 / _pln ; + UNTIL ( a1 a2 ) + DUP BLK) < IF BLK( - FBUF + -^ EDPOS ! ELSE DROP THEN ; +: F FBUF _type _F EDPOS @ 64 / _pln ; diff --git a/blk/108 b/blk/108 index 07b1849..851f3be 100644 --- a/blk/108 +++ b/blk/108 @@ -3,8 +3,8 @@ : _rbufsz ( size of linebuf to the right of curpos ) EDPOS @ 64 MOD 63 -^ ; : i COMPILE I ; IMMEDIATE ( save overshadowed ) -: _I ( I without _pln. used in VE ) - IBUF _type _rbufsz IBUF _blen 2DUP > IF +: _I ( I without _pln and _type. used in VE ) + _rbufsz IBUF _blen 2DUP > IF TUCK - ( ilen chars-to-move ) SWAP EDPOS @ _cpos 2DUP + ( ctm ilen a a+ilen ) 3 PICK MOVE- ( ctm ilen ) @@ -12,4 +12,4 @@ ELSE DROP ( ilen becomes rbuffsize ) THEN DUP IBUF EDPOS @ _cpos ROT MOVE ( ilen ) EDPOS +! BLK!! ; -: I _I EDPOS @ 64 / _pln ; +: I IBUF _type _I EDPOS @ 64 / _pln ; diff --git a/blk/127 b/blk/127 index 17e3555..9b5b11d 100644 --- a/blk/127 +++ b/blk/127 @@ -3,3 +3,8 @@ : setpos ( -- ) EDPOS @ 64 /MOD 3 + ( header ) SWAP 3 + ( gutter ) SWAP AT-XY ; : cmv ( n -- , char movement ) acc@ * EDPOS @ + pos! ; +: buftype ( buf ln -- ) + 3 OVER AT-XY C< DUP 0xd = IF 2DROP DROP EXIT THEN + ( buf ln c ) 63 nspcs SWAP 4 SWAP AT-XY ( buf c ) + SWAP DUP _zbuf BEGIN ( c a ) + C!+ C< TUCK 0x0d = UNTIL ( c a ) C! ; diff --git a/blk/128 b/blk/128 index 4c580e0..73a3610 100644 --- a/blk/128 +++ b/blk/128 @@ -2,8 +2,8 @@ : $g ACC @ selblk 0acc ; : $[ BLK> @ acc@ - selblk ; : $] BLK> @ acc@ + selblk ; -: $I mode! 'I' EMIT 3 1 AT-XY _I contents mode! SPC ; -: $F mode! 'F' EMIT 3 2 AT-XY _F setpos mode! SPC ; +: $I mode! 'I' EMIT IBUF 1 buftype _I contents mode! SPC ; +: $F mode! 'F' EMIT FBUF 2 buftype _F setpos mode! SPC ; : $E E contents ; : $X acc@ X contents ; : $h -1 cmv ; : $l 1 cmv ; : $k -64 cmv ; : $j 64 cmv ;