1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-25 05:38:05 +11:00

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.
This commit is contained in:
Virgil Dupras 2020-06-06 21:46:46 -04:00
parent 204a66277e
commit b22ab8437b
7 changed files with 24 additions and 12 deletions

11
blk/122
View File

@ -6,8 +6,11 @@
'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,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 ;

View File

@ -1,13 +1,12 @@
: _pos! 1023 MIN DUP 0< IF DROP 0 THEN EDPOS ! ;
: $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( - _pos! ; 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 1+ BEGIN C@+ WS? NOT UNTIL BEGIN C@+ WS? UNTIL LOOP
2- BLK( - _pos! ; 2- BLK( - pos! ;
: $b EDPOS @ BLK( + acc@ 0 DO : $b EDPOS @ BLK( + acc@ 0 DO
1- BEGIN C@- WS? NOT UNTIL BEGIN C@- WS? UNTIL LOOP 1- BEGIN C@- WS? NOT UNTIL BEGIN C@- WS? UNTIL LOOP
2+ BLK( - _pos! ; 2+ BLK( - pos! ;
: $B EDPOS @ BLK( + acc@ 0 DO : $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( - _pos! ; 1+ BLK( - pos! ;

View File

@ -1,3 +1,7 @@
: $f EDPOS @ PREVPOS @ 2DUP = IF 2DROP EXIT THEN
2DUP > IF DUP pos! SWAP THEN
( p1 p2, p1 < p2 ) OVER - ( pos len ) FBUF _zbuf
SWAP _cpos FBUF ( len src dst ) ROT MOVE ;
: $R ( replace mode ) : $R ( replace mode )
mode! 'R' EMIT mode! 'R' EMIT
BEGIN setpos C< DUP 0xd = NOT IF BEGIN setpos C< DUP 0xd = NOT IF

View File

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