editor: add edit buffer
Also, add word "C!+" and fix PSP leak in FILL.
This commit is contained in:
parent
792c781614
commit
5bf3baff05
1
blk/050
1
blk/050
@ -7,6 +7,7 @@ Memory
|
||||
C@ a -- c Set c to byte at address a
|
||||
C@+ a -- a+1 c Fetch c from a and inc a.
|
||||
C! c a -- Store byte c in address a
|
||||
C!+ c a -- a+1 Store byte c in a and inc a.
|
||||
CURRENT -- a Set a to wordref of last added entry.
|
||||
CURRENT* -- a A pointer to active CURRENT*. Useful
|
||||
when we have multiple active dicts.
|
||||
|
11
blk/104
11
blk/104
@ -1,5 +1,6 @@
|
||||
( Cursor position in buffer. EDPOS/64 is line number )
|
||||
VARIABLE EDPOS
|
||||
CREATE EDBUF 64 ALLOT
|
||||
: _cpos BLK( + ;
|
||||
: _lpos 64 * _cpos ;
|
||||
: _pln ( lineno -- )
|
||||
@ -7,7 +8,9 @@ VARIABLE EDPOS
|
||||
I EDPOS @ _cpos = IF '^' EMIT THEN
|
||||
I C@ DUP 0x20 < IF DROP 0x20 THEN
|
||||
EMIT
|
||||
LOOP ( lno )
|
||||
1+ . ;
|
||||
( user-facing lines are 1-based )
|
||||
: T 1- DUP 64 * EDPOS ! _pln ;
|
||||
LOOP ( lno ) 1+ . ;
|
||||
: _zbuf EDBUF 64 0 FILL ;
|
||||
: _type ( -- )
|
||||
C< DUP 0xd = IF DROP EXIT THEN _zbuf EDBUF BEGIN ( c a )
|
||||
C!+ C< SWAP OVER 0x0d = UNTIL ( c a )
|
||||
2DROP ;
|
||||
|
15
blk/105
15
blk/105
@ -1,16 +1,7 @@
|
||||
: P
|
||||
EDPOS @ _cpos C<
|
||||
64 0 DO ( bpos c )
|
||||
DUP 0xd = IF DROP 0 THEN
|
||||
2DUP SWAP I + C!
|
||||
DUP IF DROP C< THEN
|
||||
LOOP
|
||||
2DROP
|
||||
BLK!!
|
||||
;
|
||||
|
||||
( user-facing lines are 1-based )
|
||||
: T 1- DUP 64 * EDPOS ! _pln ;
|
||||
: P _type EDBUF EDPOS @ _cpos 64 MOVE BLK!! ;
|
||||
: _mvln+ ( ln -- move ln 1 line further )
|
||||
DUP 14 > IF DROP EXIT THEN
|
||||
_lpos DUP 64 + 64 MOVE
|
||||
;
|
||||
|
||||
|
4
blk/155
4
blk/155
@ -1,6 +1,4 @@
|
||||
: FILL ( a n b -- )
|
||||
SWAP 2 PICK + ( a b a+n ) ROT ( b a+n a ) DO ( b )
|
||||
DUP I C!
|
||||
LOOP
|
||||
;
|
||||
|
||||
LOOP DROP ;
|
||||
|
2
blk/436
2
blk/436
@ -10,3 +10,5 @@
|
||||
|
||||
( a -- a+1 c )
|
||||
: C@+ DUP C@ SWAP 1+ SWAP ;
|
||||
( c a -- a+1 )
|
||||
: C!+ SWAP OVER C! 1+ ;
|
||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user