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

editor: implement F

This commit is contained in:
Virgil Dupras 2020-05-01 21:52:38 -04:00
parent 86539d2a03
commit 2a578b3352
9 changed files with 27 additions and 17 deletions

View File

@ -1,6 +1,8 @@
Disk Disk
BLK> -- a Address of the current block variable. BLK> -- a Address of the current block variable.
BLK( -- a Beginning addr of blk buf.
BLK) -- a Ending addr of blk buf.
COPY s d -- Copy contents of s block to d block. COPY s d -- Copy contents of s block to d block.
FLUSH -- Write current block to disk if dirty. FLUSH -- Write current block to disk if dirty.
LIST n -- Prints the contents of the block n on screen LIST n -- Prints the contents of the block n on screen
@ -12,7 +14,3 @@ WIPE -- Empties current block

View File

@ -1,8 +1,7 @@
T ( n -- ): select line n for editing. T ( n -- ): select line n for editing.
P xxx: put typed line on selected line. P xxx: put typed line on selected line.
U xxx: insert typed line on selected line. U xxx: insert typed line on selected line.
F xxx: find typed string in block.

View File

@ -1,5 +1,5 @@
152 LOAD ( extras ) 152 LOAD ( extras )
103 106 LOADR 103 107 LOADR
: BROWSE : BROWSE
100 _LIST 100 _LIST

View File

@ -1,6 +1,7 @@
( 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 CREATE IBUF 64 ALLOT
CREATE FBUF 64 ALLOT
: _cpos BLK( + ; : _cpos BLK( + ;
: _lpos 64 * _cpos ; : _lpos 64 * _cpos ;
: _pln ( lineno -- ) : _pln ( lineno -- )
@ -9,8 +10,4 @@ CREATE EDBUF 64 ALLOT
I C@ DUP 0x20 < IF DROP 0x20 THEN I C@ DUP 0x20 < IF DROP 0x20 THEN
EMIT EMIT
LOOP ( lno ) 1+ . ; LOOP ( lno ) 1+ . ;
: _zbuf EDBUF 64 0 FILL ; : _zbuf 64 0 FILL ; ( buf -- )
: _type ( -- )
C< DUP 0xd = IF DROP EXIT THEN _zbuf EDBUF BEGIN ( c a )
C!+ C< SWAP OVER 0x0d = UNTIL ( c a )
2DROP ;

View File

@ -1,6 +1,11 @@
: _type ( buf -- )
C< DUP 0xd = IF DROP EXIT THEN OVER DUP _zbuf ( c a )
BEGIN ( c a )
C!+ C< SWAP
OVER 0x0d = UNTIL ( c a ) C! ;
( user-facing lines are 1-based ) ( user-facing lines are 1-based )
: T 1- DUP 64 * EDPOS ! _pln ; : T 1- DUP 64 * EDPOS ! _pln ;
: P _type EDBUF EDPOS @ _cpos 64 MOVE BLK!! ; : P IBUF _type IBUF EDPOS @ _cpos 64 MOVE 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

View File

@ -1,7 +1,5 @@
: U : U
15 EDPOS @ 64 / - 0 DO 15 EDPOS @ 64 / - 0 DO
14 I - _mvln+ 14 I - _mvln+
LOOP LOOP P
P
; ;

12
blk/107 Normal file
View File

@ -0,0 +1,12 @@
: F
FBUF _type FBUF EDPOS @ _cpos ( a1 a2 )
BEGIN
C@+ ROT ( a2+1 c2 a1 ) C@+ ROT ( a2+1 a1+1 c1 c2 )
= NOT IF DROP FBUF THEN
SWAP OVER C@ 0xd = ( a1 a2 f1 )
OVER BLK) = OR ( a1 a2 f1|f2 )
UNTIL
DUP BLK) < IF BLK( - FBUF + -^ EDPOS ! THEN
EDPOS @ 64 / _pln
;

View File

@ -8,5 +8,6 @@
( Whether buffer is dirty ) ( Whether buffer is dirty )
: BLKDTY 6 BLKMEM+ ; : BLKDTY 6 BLKMEM+ ;
: BLK( 8 BLKMEM+ ; : BLK( 8 BLKMEM+ ;
: BLK) BLK( 1024 + ;

Binary file not shown.