From d0855ce6b23c6186d3aaf2232881f1935ecb41ba Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Thu, 11 Feb 2021 21:48:34 -0800 Subject: [PATCH] Moved block editor into its own vocabulary. --- ueforth/common/blocks.fs | 9 +++++++-- ueforth/site/index.html | 24 +++++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ueforth/common/blocks.fs b/ueforth/common/blocks.fs index 7b6f9e2..83ac57c 100644 --- a/ueforth/common/blocks.fs +++ b/ueforth/common/blocks.fs @@ -41,16 +41,21 @@ forth definitions internals : load ( n -- ) block 1024 evaluate ; : 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 ) : list ( n -- ) scr ! ." Block " scr @ . cr scr @ block 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 : @line ( n -- ) 64 * scr @ block + ; : e' ( n -- ) @line clobber-line drop update ; 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 ; : 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 ; : a ( n "line" -- ) dup @line over 1+ @line 16 @line over - cmove> r ; -forth definitions +only forth definitions diff --git a/ueforth/site/index.html b/ueforth/site/index.html index dca019a..3065b6c 100644 --- a/ueforth/site/index.html +++ b/ueforth/site/index.html @@ -140,21 +140,39 @@ ORDER ( -- ) Print the vocabulary search order SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain -
Block Editor
+
Blocks
 USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo
 OPEN-BLOCKS ( a n -- ) Open a file as the block file
 LOAD ( n -- ) Evaluate a block
 THRU ( a b -- ) Load blocks a thru b
 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
+
+ +
Block Editor
+These words are available inside the EDITOR vocabulary. +
 WIPE ( -- ) Blank out the current block
+L ( -- ) List the current block
 D ( n -- ) Delete 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
 A ( n "text" -- ) Add (insert) a line in the current block
+P ( -- ) Move to the previous block
+N ( -- ) Move to the next block
+
+ +
Utilities
+
 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
 

ESP32 Arduino