etherforth_logo

Node 212

This node takes care of cursor movement. Here we define elementary words for cursor pointer movement one symbol forward and backward.

Source code

editor node 312 node 213 node 211 node 212
212 symbols
ptr 00 @p drop @p ; ptr! 01 !p ; 0 ,
12/ 03 w-s 2/ 2/ 2/ 2/ 2/ 2/
6/ 05 2/ 2/ 2/ 2/ 2/ 2/
0/ 07 3F and ;
w@ 09 p-w @p !b 2/ . @p ! @ !p 2/ !b @b . @p !b ; ;
cu! 0E n 5718 cu! !b !b ;
array 10 pop . + push ;
tab 12 array 12/ ; 6/ ; 0/ ;
sym 16 p-ps dup w@ over 3 and tab ;
+p 1A -p 1 +-p 1C dup ptr . + 3 over over and or
if drop ; then drop . + ;
-p 23 -p -1 +-p -if dup or then ;
+s 28 +p sym dup 3C eob or if drop ! ptr! ; then - ! ;
-s 30 ptr if -p dup ptr! then sym ! ;
upd 36 n ptr!
cu 37 ptr cu! ; 39

init right a! down b! r-l- ; 3E

4 d 3 r 0 ether

Definitions

ptr, ptr!
Keep current pointer (cursor position).
12/, 6/, 0/
Extract symbol s from word w.
w@
Take pointer p and return corresponding word w from block buffer. We access buffer directly via port execution in node 312.
cu!
Set pointer n in node 412.
array
This is an array defining word.
tab
This is an array of execution vectors.
sym
Take pointer p and return corresponding symbol s. Keep p on stack.
+p, -p
Move current cursor one symbol right/left and return updated pointer p. Word -p also checks p doesn't get below zero.
+s, -s
Move current cursor one symbol right/left and update pointer ptr!. Updated pointer is kept between zero and one symbol before the position of eob symbol in buffer. Symbol s at the updated cursor position is sent to RIGHT. If +s hits eob we send a negative number to RIGHT as a flag.
upd
Update pointer to n and fall through to
cu
Get pointer ptr and set cursor to that position.
init
Set registers A and B, and jump to RIGHT and LEFT.

Description