Moved block editor into its own vocabulary.

This commit is contained in:
Brad Nelson
2021-02-11 21:48:34 -08:00
parent 45071d9eeb
commit d0855ce6b2
2 changed files with 28 additions and 5 deletions

View File

@ -41,16 +41,21 @@ forth definitions internals
: load ( n -- ) block 1024 evaluate ; : load ( n -- ) block 1024 evaluate ;
: thru ( a b -- ) over - 1+ for aft dup >r load r> 1+ then next drop ; : thru ( a b -- ) over - 1+ for aft dup >r load r> 1+ then next drop ;
( Utility )
: copy ( from to -- )
swap block pad 1024 cmove pad swap block 1024 cmove update ;
( Editing ) ( Editing )
: list ( n -- ) scr ! ." Block " scr @ . cr scr @ block : list ( n -- ) scr ! ." Block " scr @ . cr scr @ block
15 for dup 63 type [char] | emit space 15 r@ - . cr 64 + next drop ; 15 for dup 63 type [char] | emit space 15 r@ - . cr 64 + next drop ;
: l scr @ list ; : n 1 scr +! l ; : p -1 scr +! l ;
internals definitions internals definitions
: @line ( n -- ) 64 * scr @ block + ; : @line ( n -- ) 64 * scr @ block + ;
: e' ( n -- ) @line clobber-line drop update ; : e' ( n -- ) @line clobber-line drop update ;
forth definitions internals forth definitions internals
vocabulary editor also editor definitions
: l scr @ list ; : n 1 scr +! l ; : p -1 scr +! l ;
: wipe 15 for r@ e' next l ; : e e' l ; : wipe 15 for r@ e' next l ; : e e' l ;
: d ( n -- ) dup 1+ @line swap @line 15 @line over - cmove 15 e ; : d ( n -- ) dup 1+ @line swap @line 15 @line over - cmove 15 e ;
: r ( n "line" -- ) 0 parse 64 min rot dup e @line swap cmove l ; : r ( n "line" -- ) 0 parse 64 min rot dup e @line swap cmove l ;
: a ( n "line" -- ) dup @line over 1+ @line 16 @line over - cmove> r ; : a ( n "line" -- ) dup @line over 1+ @line 16 @line over - cmove> r ;
forth definitions only forth definitions

View File

@ -140,21 +140,39 @@ ORDER ( -- ) Print the vocabulary search order
SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain
</pre> </pre>
<h5>Block Editor</h5> <h5>Blocks</h5>
<pre> <pre>
USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo
OPEN-BLOCKS ( a n -- ) Open a file as the block file OPEN-BLOCKS ( a n -- ) Open a file as the block file
LOAD ( n -- ) Evaluate a block LOAD ( n -- ) Evaluate a block
THRU ( a b -- ) Load blocks a thru b THRU ( a b -- ) Load blocks a thru b
LIST ( n -- ) List a block LIST ( n -- ) List a block
L ( -- ) List the current block BLOCK ( n -- a ) Get a 1024 byte block
BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents
UPDATE ( -- ) Mark the last block modified
FLUSH ( -- ) Save and empty all buffers
EMPTY-BUFFERS ( -- ) Empty all buffers
SAVE-BUFFERS ( -- ) Save all buffers
SCR ( -- a ) Pointer to last listed block
</pre>
<h5>Block Editor</h5>
These words are available inside the <code>EDITOR</code> vocabulary.
<pre>
WIPE ( -- ) Blank out the current block WIPE ( -- ) Blank out the current block
L ( -- ) List the current block
D ( n -- ) Delete a line in the current block D ( n -- ) Delete a line in the current block
E ( n -- ) Clear a line in the current block E ( n -- ) Clear a line in the current block
R ( n "text" -- ) Replace a line in the current block R ( n "text" -- ) Replace a line in the current block
A ( n "text" -- ) Add (insert) a line in the current block A ( n "text" -- ) Add (insert) a line in the current block
P ( -- ) Move to the previous block
N ( -- ) Move to the next block
</pre>
<h5>Utilities</h5>
<pre>
SEE ( "name" -- ) Attempt to decompile a word SEE ( "name" -- ) Attempt to decompile a word
VARIABLE ECHO -- Determines if commands are echoed ECHO ( -- a ) -- Address of flag that determines if commands are echoed
</pre> </pre>
<h3>ESP32 Arduino</h3> <h3>ESP32 Arduino</h3>