1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-26 10:28:05 +11:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Virgil Dupras
1871c46614 VE: add backspace support in replace mode 2020-06-11 22:29:05 -04:00
Virgil Dupras
dc368597a6 VE: Add dirtiness indicator in status bar
Written from VE!
2020-06-11 21:52:08 -04:00
Virgil Dupras
838c88459b Make BLK@ FLUSH only if loading a different block
Otherwise, when editing a file with VE, we would constantly write
to disk, which is a bit inefficient.
2020-06-11 21:42:52 -04:00
Virgil Dupras
e317e9cc78 VE: use system input buffer for IBUF and FBUF typing
This gives us backspace handling. Also, remove all usages of C<
which allows us to remove the C<* override.
2020-06-11 20:45:46 -04:00
15 changed files with 74 additions and 56 deletions

26
blk/121
View File

@ -1,16 +1,16 @@
All keystrokes are directly interpreted by VE and have the
effect described below.
The status line displays the active block number, then the
"modifier" and then the cursor position. When the block is dir-
ty, an "*" is displayed next. At the right corner, a mode letter
can appear. 'R' for replace, 'I' for insert, 'F' for find.
Pressing a 0-9 digit accumulates that digit into what is named
the "modifier". That modifier affects the behavior of many
keystokes described below. The modifier starts at zero, but
most commands interpret a zero as a 1 so that they can have an
effect.
'g' selects the block specified by the modifier as the current
block. Any change made to the previously selected block is
saved beforehand.
'[' and ']' advances the selected block by "modifier". 't' opens
the previously opened block.
(cont.)
(cont.)

24
blk/122
View File

@ -1,16 +1,16 @@
'h' and 'l' move the cursor by "modifier" characters. 'j' and
'k', by lines.
All keystrokes are directly interpreted by VE and have the
effect described below.
'H' goes to the beginning of the line, 'L' to the end.
Pressing a 0-9 digit accumulates that digit into what is named
the "modifier". That modifier affects the behavior of many
keystokes described below. The modifier starts at zero, but
most commands interpret a zero as a 1 so that they can have an
effect.
'w' moves forward by "modifier" words. 'b' moves backward.
'W' moves to end-of-word. 'B', backwards.
'g' selects the block specified by the modifier as the current
block. Any change made to the previously selected block is
saved beforehand.
'I', 'F', 'Y', 'X' and 'E' invoke the corresponding command
from the Block Editor (B100). Refer to documentation there.
'o' inserts a blank line after the cursor. 'O', before.
'D' deletes "modifier" lines at the cursor. The first of those
lines is copied to IBUF.
'[' and ']' advances the selected block by "modifier". 't' opens
the previously opened block.
(cont.)

20
blk/123
View File

@ -1,16 +1,16 @@
'f' puts the contents of your previous cursor movement into
FBUF. If that movement was a forward movement, it brings the
cursor back where it was. This allows for an efficient combi-
nation of movements and 'E'. For example, if you want to delete
the next word, you type 'w', then 'f', then check your FBUF to
be sure, then press 'E'.
'R' goes into replace mode at current cursor position.
Following keystrokes replace current character and advance
cursor. Press return to return to normal mode.
'h' and 'l' move the cursor by "modifier" characters. 'j' and
'k', by lines.
'H' goes to the beginning of the line, 'L' to the end.
'w' moves forward by "modifier" words. 'b' moves backward.
'W' moves to end-of-word. 'B', backwards.
'I', 'F', 'Y', 'X' and 'E' invoke the corresponding command
'o' inserts a blank line after the cursor. 'O', before.
'D' deletes "modifier" lines at the cursor. The first of those
lines is copied to IBUF.
(cont.)

16
blk/124 Normal file
View File

@ -0,0 +1,16 @@
'f' puts the contents of your previous cursor movement into
FBUF. If that movement was a forward movement, it brings the
cursor back where it was. This allows for an efficient combi-
nation of movements and 'E'. For example, if you want to delete
the next word, you type 'w', then 'f', then check your FBUF to
be sure, then press 'E'.
'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

@ -7,10 +7,10 @@ CREATE PREVPOS 0 , CREATE PREVBLK 0 ,
: clrscr LINES 0 DO i aty COLS nspcs LOOP ;
: gutter ( ln n ) OVER + SWAP DO 67 i AT-XY '|' EMIT LOOP ;
: status 0 aty ." BLK" SPC BLK> ? SPC ACC ?
SPC EDPOS @ 64 /MOD . ',' EMIT . 10 nspcs ;
SPC EDPOS @ 64 /MOD . ',' EMIT . SPC
BLKDTY @ IF '*' EMIT THEN 10 nspcs ;
: contents 3 aty BLK> @ LIST 3 16 gutter ;
: selblk BLK> @ PREVBLK ! BLK@ contents ;
: mode! ( c -- ) 63 0 AT-XY ;

View File

@ -4,10 +4,10 @@
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 C!+ DUP 63 + SWAP DO
C< DUP 0x0d = IF LEAVE THEN i C! LOOP ;
3 OVER AT-XY KEY DUP EMIT
DUP 0x20 < IF 2DROP DROP EXIT THEN
( buf ln c ) 63 nspcs SWAP 4 SWAP AT-XY ( buf c ) SWAP C!+
IN( _zbuf (rdln) IN( SWAP 63 MOVE ;

View File

@ -4,8 +4,9 @@
SWAP _cpos FBUF ( len src dst ) ROT MOVE ;
: $R ( replace mode )
mode! 'R' EMIT
BEGIN setpos C< DUP 0xd = NOT IF
EDPOS @ _cpos C! 1 EDPOS +! BLK!! 0
BEGIN setpos KEY DUP BS? IF -1 EDPOS +! DROP 0 THEN
DUP 0x20 >= IF
DUP EMIT EDPOS @ _cpos C! 1 EDPOS +! BLK!! 0
THEN UNTIL mode! SPC contents ;
: $O EDPOS @ 0x3c0 ( 15 * 64 ) >= IF EXIT THEN
_U EDPOS @ 0x3c0 AND DUP pos! _cpos _zbuf BLK!! contents ;
@ -13,4 +14,3 @@
: $D $H 64 icpy
acc@ 0 DO 16 EDPOS @ 64 / DO i _mvln- LOOP LOOP
BLK!! contents ;

View File

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

View File

@ -13,3 +13,4 @@

View File

@ -1,7 +1,7 @@
: WIPE BLK( 1024 0 FILL BLK!! ;
( src dst -- )
: COPY SWAP BLK@ BLK> ! BLK! ;
: COPY FLUSH SWAP BLK@ BLK> ! BLK! ;

View File

@ -12,3 +12,5 @@
PREV CURRENT !
;
: EMPTY LIT< _sys FIND IF DUP HERE ! CURRENT ! THEN ;

View File

@ -4,13 +4,13 @@
;
: FLUSH BLKDTY @ IF BLK! THEN ;
: BLK@ ( n -- )
FLUSH
DUP BLK> @ = IF DROP EXIT THEN
DUP BLK> ! BLK@* @ EXECUTE
;
FLUSH DUP BLK> ! BLK@* @ EXECUTE ;
: BLK!! 1 BLKDTY ! ;

View File

@ -1,16 +1,16 @@
( handle backspace: go back one char in IN>, if possible, then
emit BS + SPC + BS )
: (inbs)
: _bs
( already at IN( ? )
IN> @ IN( = IF EXIT THEN
IN> @ 1- IN> !
BS SPC BS
;
( del is same as backspace )
: BS? DUP 0x7f = SWAP 0x8 = OR ;
: KEY
85 RAM+ @ ( (key) override )
?DUP IF EXECUTE ELSE (key) THEN ;
( cont.: read one char into input buffer and returns whether we
should continue, that is, whether CR was not met. )

View File

@ -1,10 +1,9 @@
: (rdlnc) ( -- c )
( buffer overflow? same as if we typed a newline )
IN> @ IN) = IF 0x0a ELSE KEY THEN ( c )
DUP 0x7f = IF DROP 0x8 THEN ( del? same as backspace )
DUP 0x0a = IF DROP 0xd THEN ( lf? same as cr )
( bacspace? handle and exit )
DUP 0x8 = IF (inbs) EXIT THEN
DUP BS? IF _bs EXIT THEN
( echo back )
DUP EMIT ( c )
( write and advance )

Binary file not shown.