Compare commits

...

2 Commits

Author SHA1 Message Date
Virgil Dupras
a1b99275e6 VE: Add replace mode 2020-06-05 11:01:26 -04:00
Virgil Dupras
e7a6c777c7 VE: refactor mode indicators
The indicator is going to be empty most of the time and will be
emitted by the mode changer directly. That's going to the upper-right
corner and the status bar avoids emitting in that area.
2020-06-05 10:38:05 -04:00
5 changed files with 17 additions and 10 deletions

View File

@ -4,3 +4,7 @@
'I' inserts text by calling the "I" command from the Block 'I' inserts text by calling the "I" command from the Block
editor. editor.
'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,13 +1,12 @@
CREATE CMD 2 C, '$' C, 0 C, CREATE CMD 2 C, '$' C, 0 C,
VARIABLE MODE VARIABLE MODEC
: 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 ;
: nspcs ( n -- , spit n space ) 0 DO SPC LOOP ; : nspcs ( n -- , spit n space ) 0 DO SPC LOOP ;
: aty 0 SWAP AT-XY ; : aty 0 SWAP AT-XY ;
: clrln DUP aty COLS nspcs aty ; : clrscr LINES 0 DO i aty COLS nspcs LOOP ;
: clrscr LINES 0 DO i clrln LOOP ; : status 0 aty ." BLK" SPC BLK> ? SPC ACC ?
: status 0 clrln ." BLK" SPC BLK> ? SPC ACC ? SPC EDPOS @ 64 /MOD . ',' EMIT . 10 nspcs ;
SPC EDPOS @ 64 /MOD . ',' EMIT . SPC MODEC C@ EMIT ;
: contents 3 aty BLK> @ LIST ; : contents 3 aty BLK> @ LIST ;
: selblk BLK@ contents ; : selblk BLK@ contents ;
: mode! ( c -- ) 63 0 AT-XY ;

View File

@ -6,7 +6,7 @@
: $g ACC @ selblk 0acc ; : $g ACC @ selblk 0acc ;
: $[ BLK> @ acc@ - selblk ; : $[ BLK> @ acc@ - selblk ;
: $] BLK> @ acc@ + selblk ; : $] BLK> @ acc@ + selblk ;
: $I 3 1 AT-XY I contents ; : $I mode! 'I' EMIT 3 1 AT-XY I contents mode! SPC ;
: $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 EDPOS ! ;
: $L 0acc EDPOS @ 0x3f OR EDPOS ! ; : $L 0acc EDPOS @ 0x3f OR EDPOS ! ;

View File

@ -4,8 +4,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( - DUP 0< IF DROP 0 THEN EDPOS ! ; 1+ BLK( - DUP 0< IF DROP 0 THEN EDPOS ! ;
: handleM ( c -- f ) : $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 '0' '9' =><= IF num 0 EXIT THEN
DUP CMD 2+ C! CMD FIND IF EXECUTE ELSE DROP THEN DUP CMD 2+ C! CMD FIND IF EXECUTE ELSE DROP THEN
UPPER 'Q' = ; UPPER 'Q' = ;
: modeM ['] handleM MODE ! 'M' MODEC C! ;

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 ! modeM contents clrscr 0acc 0 EDPOS ! contents
BEGIN status bufs setpos KEY MODE @ EXECUTE UNTIL BEGIN status bufs setpos KEY handle UNTIL
0 0x08 RAM+ ! 19 aty ; 0 0x08 RAM+ ! 19 aty ;