mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-05 08:40:54 +11:00
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 -- c Set c to byte at address a
|
||||||
C@+ a -- a+1 c Fetch c from a and inc 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 -- 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 Set a to wordref of last added entry.
|
||||||
CURRENT* -- a A pointer to active CURRENT*. Useful
|
CURRENT* -- a A pointer to active CURRENT*. Useful
|
||||||
when we have multiple active dicts.
|
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 )
|
( Cursor position in buffer. EDPOS/64 is line number )
|
||||||
VARIABLE EDPOS
|
VARIABLE EDPOS
|
||||||
|
CREATE EDBUF 64 ALLOT
|
||||||
: _cpos BLK( + ;
|
: _cpos BLK( + ;
|
||||||
: _lpos 64 * _cpos ;
|
: _lpos 64 * _cpos ;
|
||||||
: _pln ( lineno -- )
|
: _pln ( lineno -- )
|
||||||
@ -7,7 +8,9 @@ VARIABLE EDPOS
|
|||||||
I EDPOS @ _cpos = IF '^' EMIT THEN
|
I EDPOS @ _cpos = IF '^' EMIT THEN
|
||||||
I C@ DUP 0x20 < IF DROP 0x20 THEN
|
I C@ DUP 0x20 < IF DROP 0x20 THEN
|
||||||
EMIT
|
EMIT
|
||||||
LOOP ( lno )
|
LOOP ( lno ) 1+ . ;
|
||||||
1+ . ;
|
: _zbuf EDBUF 64 0 FILL ;
|
||||||
( user-facing lines are 1-based )
|
: _type ( -- )
|
||||||
: T 1- DUP 64 * EDPOS ! _pln ;
|
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
|
( user-facing lines are 1-based )
|
||||||
EDPOS @ _cpos C<
|
: T 1- DUP 64 * EDPOS ! _pln ;
|
||||||
64 0 DO ( bpos c )
|
: P _type EDBUF EDPOS @ _cpos 64 MOVE BLK!! ;
|
||||||
DUP 0xd = IF DROP 0 THEN
|
|
||||||
2DUP SWAP I + C!
|
|
||||||
DUP IF DROP C< THEN
|
|
||||||
LOOP
|
|
||||||
2DROP
|
|
||||||
BLK!!
|
|
||||||
;
|
|
||||||
|
|
||||||
: _mvln+ ( ln -- move ln 1 line further )
|
: _mvln+ ( ln -- move ln 1 line further )
|
||||||
DUP 14 > IF DROP EXIT THEN
|
DUP 14 > IF DROP EXIT THEN
|
||||||
_lpos DUP 64 + 64 MOVE
|
_lpos DUP 64 + 64 MOVE
|
||||||
;
|
;
|
||||||
|
|
||||||
|
4
blk/155
4
blk/155
@ -1,6 +1,4 @@
|
|||||||
: FILL ( a n b -- )
|
: FILL ( a n b -- )
|
||||||
SWAP 2 PICK + ( a b a+n ) ROT ( b a+n a ) DO ( b )
|
SWAP 2 PICK + ( a b a+n ) ROT ( b a+n a ) DO ( b )
|
||||||
DUP I C!
|
DUP I C!
|
||||||
LOOP
|
LOOP DROP ;
|
||||||
;
|
|
||||||
|
|
||||||
|
2
blk/436
2
blk/436
@ -10,3 +10,5 @@
|
|||||||
|
|
||||||
( a -- a+1 c )
|
( a -- a+1 c )
|
||||||
: C@+ DUP C@ SWAP 1+ SWAP ;
|
: 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