Compare commits

...

3 Commits

Author SHA1 Message Date
Virgil Dupras
c6016cd429 VE: fix buffer overflow with 'f' and make 'H' and 'L' affect 'f' 2020-06-06 21:59:22 -04:00
Virgil Dupras
b22ab8437b VE: add command 'f'
Kinda proud of this one. Efficiently piggy-backing on the Block
Editor, keeping things simple, and yet, building power into the
editor.
2020-06-06 21:46:46 -04:00
Virgil Dupras
204a66277e VE: replace 'W' with 'b' and implement 'W' and 'B'
Which are end-of-word movements.
2020-06-06 21:01:35 -04:00
8 changed files with 54 additions and 34 deletions

14
blk/122
View File

@ -1,12 +1,16 @@
'H' goes to the beginning of the line, 'L' to the end. 'H' goes to the beginning of the line, 'L' to the end.
'w' moves forward by a word. 'W' moves backward by a word. 'w' moves forward by a word. 'b' moves backward by a word.
'W' moves to end-of-word. 'B' moves backward to end-of-word.
'I', 'F' and 'E' invoke the corresponding command from the 'I', 'F' and 'E' invoke the corresponding command from the
Block Editor (B100). Refer to documentation there. Block Editor (B100). Refer to documentation there.
'X' deletes "modifier" characters following cursor. 'f' puts the contents of your previous cursor movement into the
find buffer. If that movement was a forward movement, it brings
the cursor back where it was. This allows for an efficient
combination of movements and 'E'. For example, if you want to
delete the next word, you type 'w', then 'f', then check your
"F" buffer to be sure, then press 'E'.
'R' goes into replace mode at current cursor position. 'X' deletes "modifier" characters following cursor. (cont.)
Following keystrokes replace current character and advance
cursor. Press return to return to normal mode.

4
blk/123 Normal file
View File

@ -0,0 +1,4 @@
'R' goes into replace mode at current cursor position.
Following keystrokes replace current character and advance
cursor. Press return to return to normal mode.

View File

@ -1,3 +1,3 @@
'? UPPER NOT [IF] 33 LOAD+ [THEN] DROP ( B158 ) '? UPPER NOT [IF] 33 LOAD+ [THEN] DROP ( B158 )
-23 LOAD+ ( B102, block editor ) -23 LOAD+ ( B102, block editor )
1 4 LOADR+ 1 5 LOADR+

View File

@ -1,4 +1,5 @@
CREATE CMD 2 C, '$' C, 0 C, CREATE CMD 2 C, '$' C, 0 C,
VARIABLE PREVPOS
: 0acc 0 ACC ! ; : 0acc 0 ACC ! ;
: acc@ ACC @ 1 MAX 0acc ; : acc@ ACC @ 1 MAX 0acc ;
: num ACC @ SWAP _pdacc IF DROP ELSE ACC ! THEN ; : num ACC @ SWAP _pdacc IF DROP ELSE ACC ! THEN ;
@ -10,3 +11,5 @@ CREATE CMD 2 C, '$' C, 0 C,
: contents 3 aty BLK> @ LIST ; : contents 3 aty BLK> @ LIST ;
: selblk BLK@ contents ; : selblk BLK@ contents ;
: mode! ( c -- ) 63 0 AT-XY ; : mode! ( c -- ) 63 0 AT-XY ;
: pos! EDPOS @ PREVPOS !
1023 MIN DUP 0< IF DROP 0 THEN EDPOS ! ;

View File

@ -1,7 +1,6 @@
: setpos EDPOS @ 64 /MOD : setpos EDPOS @ 64 /MOD
3 + ( header ) SWAP 3 + ( gutter ) SWAP AT-XY ; 3 + ( header ) SWAP 3 + ( gutter ) SWAP AT-XY ;
: pos+ EDPOS @ + 1024 MOD EDPOS ! ; : cmv ( n -- , char movement ) acc@ * EDPOS @ + pos! ;
: cmv ( n -- , char movement ) acc@ * pos+ ;
: $; 0acc ; : $; 0acc ;
: $g ACC @ selblk 0acc ; : $g ACC @ selblk 0acc ;
: $[ BLK> @ acc@ - selblk ; : $[ BLK> @ acc@ - selblk ;
@ -11,5 +10,5 @@
: $E E contents ; : $E E contents ;
: $X acc@ X contents ; : $X acc@ X contents ;
: $h -1 cmv ; : $l 1 cmv ; : $k -64 cmv ; : $j 64 cmv ; : $h -1 cmv ; : $l 1 cmv ; : $k -64 cmv ; : $j 64 cmv ;
: $H 0acc EDPOS @ 0x3c0 AND EDPOS ! ; : $H 0acc EDPOS @ 0x3c0 AND pos! ;
: $L 0acc EDPOS @ 0x3f OR EDPOS ! ; : $L 0acc EDPOS @ 0x3f OR pos! ;

19
blk/128
View File

@ -1,15 +1,12 @@
: $w EDPOS @ BLK( + acc@ 0 DO : $w EDPOS @ BLK( + acc@ 0 DO
BEGIN C@+ WS? UNTIL BEGIN C@+ WS? NOT UNTIL LOOP BEGIN C@+ WS? UNTIL BEGIN C@+ WS? NOT UNTIL LOOP
1- BLK( - 1023 MIN EDPOS ! ; 1- BLK( - pos! ;
: $W EDPOS @ BLK( + acc@ 0 DO : $W EDPOS @ BLK( + acc@ 0 DO
1+ BEGIN C@+ WS? NOT UNTIL BEGIN C@+ WS? UNTIL LOOP
2- BLK( - pos! ;
: $b EDPOS @ BLK( + acc@ 0 DO
1- BEGIN C@- WS? NOT UNTIL BEGIN C@- WS? UNTIL LOOP
2+ BLK( - pos! ;
: $B EDPOS @ BLK( + acc@ 0 DO
BEGIN C@- WS? UNTIL BEGIN C@- WS? NOT UNTIL LOOP BEGIN C@- WS? UNTIL BEGIN C@- WS? NOT UNTIL LOOP
1+ BLK( - DUP 0< IF DROP 0 THEN EDPOS ! ; 1+ BLK( - pos! ;
: $R ( replace mode )
mode! 'R' EMIT
BEGIN setpos C< DUP 0xd = NOT IF
EDPOS @ _cpos C! 1 EDPOS +! BLK!! 0
THEN UNTIL mode! SPC contents ;
: handle ( c -- f )
DUP '0' '9' =><= IF num 0 EXIT THEN
DUP CMD 2+ C! CMD FIND IF EXECUTE ELSE DROP THEN
UPPER 'Q' = ;

26
blk/129
View File

@ -1,13 +1,13 @@
: bufp ( buf -- ) : $f EDPOS @ PREVPOS @ 2DUP = IF 2DROP EXIT THEN
DUP 64 + SWAP DO 2DUP > IF DUP pos! SWAP THEN
i C@ DUP 0x20 < IF DROP 0x20 THEN EMIT ( p1 p2, p1 < p2 ) OVER - 64 MIN ( pos len ) FBUF _zbuf
LOOP ; SWAP _cpos FBUF ( len src dst ) ROT MOVE ;
: bufs : $R ( replace mode )
1 aty ." I: " IBUF bufp mode! 'R' EMIT
2 aty ." F: " FBUF bufp ; BEGIN setpos C< DUP 0xd = NOT IF
: c<over KEY DUP EMIT DUP 0x0a = IF DROP 0x0d THEN ; EDPOS @ _cpos C! 1 EDPOS +! BLK!! 0
: VE ['] c<over 0x08 ( C< override ) RAM+ ! THEN UNTIL mode! SPC contents ;
clrscr 0acc 0 EDPOS ! contents : handle ( c -- f )
BEGIN status bufs setpos KEY handle UNTIL DUP '0' '9' =><= IF num 0 EXIT THEN
0 0x08 RAM+ ! 19 aty ; DUP CMD 2+ C! CMD FIND IF EXECUTE ELSE DROP THEN
UPPER 'Q' = ;

13
blk/130 Normal file
View File

@ -0,0 +1,13 @@
: bufp ( buf -- )
DUP 64 + SWAP DO
i C@ DUP 0x20 < IF DROP 0x20 THEN EMIT
LOOP ;
: bufs
1 aty ." I: " IBUF bufp
2 aty ." F: " FBUF bufp ;
: c<over KEY DUP EMIT DUP 0x0a = IF DROP 0x0d THEN ;
: VE ['] c<over 0x08 ( C< override ) RAM+ !
clrscr 0acc 0 EDPOS ! 0 PREVPOS ! contents
BEGIN status bufs setpos KEY handle UNTIL
0 0x08 RAM+ ! 19 aty ;