diff --git a/blk/000 b/blk/000 index af5a917..e2a4a36 100644 --- a/blk/000 +++ b/blk/000 @@ -4,7 +4,7 @@ This is a Forth-style filesystems which is very simple. It is a list of 1024 bytes block, organised in 16 lines of 64 columns each. You refer to blocks by numbers. You show them with LIST. You interpret them with LOAD. For a convenient way to browse -blocks, see Block Explorer at B100. +blocks, see Block editor at B100. Conventions: When you see "(cont.)" at the bottom right of a block, it means that the next block continues the same kind of diff --git a/blk/001 b/blk/001 index 0151c8e..3f43fae 100644 --- a/blk/001 +++ b/blk/001 @@ -1,4 +1,4 @@ MASTER INDEX 3 Usage 30 Dictionary - 70 Implementation notes 100 Block explorer + 70 Implementation notes 100 Block editor diff --git a/blk/100 b/blk/100 index 32059f1..4377d6b 100644 --- a/blk/100 +++ b/blk/100 @@ -1,10 +1,16 @@ -Block explorer +Block editor This is an application to conveniently browse the contents of -the disk blocks. You can launch it with "102 LOAD". +the disk blocks and edit them. You can load it with "102 LOAD". -USAGE: When loaded, the Forth interpreter is replaced by the -explorer interpreter. Typing "Q" quits the program. +Browse mode: If you execute BROWSE, the Forth interpreter is +replaced by browser's loop. Typing "Q" quits the browser. -Typing a decimal number followed by space or return lists the -contents of that block. B for previous block, N for next. +In this mode, typing a decimal number followed by space or +return lists the contents of that block. B for previous block, +N for next. + +When not in browse mode, your prompt is a regular Forth prompt +with editor words loaded. + + (cont.) diff --git a/blk/101 b/blk/101 new file mode 100644 index 0000000..8cae18f --- /dev/null +++ b/blk/101 @@ -0,0 +1,2 @@ +T ( n -- ): select line n for editing. +P xxx(return): put typed line on selected line. diff --git a/blk/102 b/blk/102 index aa7598f..1760c3a 100644 --- a/blk/102 +++ b/blk/102 @@ -1,14 +1,13 @@ -103 LOAD -VARIABLE _K +103 LOAD 104 LOAD -: PGM +: BROWSE 100 _LIST BEGIN - KEY - DUP 'Q' = IF DROP EXIT THEN - DUP 58 ( '9'+1 ) < IF _NUM - ELSE - _K ! _K (find) IF EXECUTE THEN - THEN + KEY CASE + 'Q' OF DROP EXIT ENDOF + 'B' OF B ENDOF + 'N' OF N ENDOF + _NUM + ENDCASE AGAIN -; PGM +; diff --git a/blk/103 b/blk/103 index d99ee77..4961387 100644 --- a/blk/103 +++ b/blk/103 @@ -5,5 +5,6 @@ VARIABLE ACC IF _LIST 0 THEN ACC ! ; -: B BLK> @ 1- DUP BLK> ! _LIST ; -: N BLK> @ 1+ DUP BLK> ! _LIST ; +: L BLK> @ _LIST ; +: B BLK> @ 1- BLK> ! L ; +: N BLK> @ 1+ BLK> ! L ; diff --git a/blk/104 b/blk/104 new file mode 100644 index 0000000..d311db5 --- /dev/null +++ b/blk/104 @@ -0,0 +1,13 @@ +( Line numbers for the user are 1-based, but in code, they're + 0-based. ) +VARIABLE EDPOS +: _bpos 64 * BLK( + ; +: T 1- DUP EDPOS ! _bpos (print) CRLF ; +: P + EDPOS @ _bpos C< + 64 0 DO ( bpos c ) + DUP 0xd = IF DROP 0 THEN + 2DUP SWAP I + C! + DUP IF DROP C< THEN + LOOP +; diff --git a/forth/blk.fs b/forth/blk.fs index f72bcba..d28c259 100644 --- a/forth/blk.fs +++ b/forth/blk.fs @@ -20,7 +20,7 @@ ; : BLK@ - DUP BLK> = IF DROP EXIT THEN + DUP BLK> @ = IF DROP EXIT THEN DUP BLK> ! BLK@* @ EXECUTE ;