\ load screen 910516jb ) decimal 2 32 thru \ Screeneditor variables constants 910513jb ) decimal vocabulary Screeneditor immediate Screeneditor definitions variable &old-mode variable &mode \ current mode (overstrike or insert) variable &cursor \ cursor position variable &update \ update flag variable &update-id \ update id flag variable &e-id 10 allot &e-id 12 32 fill 1 &mode ! 0 &cursor ! 0 &update ! 1 &update-id ! 6 constant %x-off \ x offset for cursor positioning 2 constant %y-off \ y offset for cursor positioning 16 constant l/scr \ lines per screen l/scr c/l * constant c/scr \ characters per screen \ -tidy e-update 910508jb ) : -tidy ( addr len --- ) over + swap do \ run through the string i c@ dup bl < swap 126 > or \ is it a control char? if bl i c! then \ yes, replace it with a blank loop ; ( -tidy replaces all control characters in a specified range with blanks ) : e-update ( --- ) 1 &update ! ; \ get-user-id 910516jb ) : get-user-id ( --- ) &e-id 10 -trailing 0= if \ is user id blank? cr ." enter date and id, e.g as 910430jb ) " 10 expect \ let the user enter 10 chars &e-id 10 -tidy \ replace control chars with blanks &e-id 10 -trailing 0= \ is user id blank? If so if 0 &update-id ! then drop \ don't bother to update id else drop then ; ( get-user-id checks to see if the user's id has been set, and if not, prompts him/her for it and saves it ) \ cfind 910509jb ) : cfind ( char addr len --- [n] flag ) >r >r 0 0 rot r> r> \ 0 0 c a l over + swap do \ 0 0 c dup i c@ = \ are the chars equal if rot 1+ \ indicate success rot rot \ put it back leave \ and get out else swap 1+ swap \ increment count then loop drop swap \ get rid of char if 1 else drop 0 then ; \ and report back \ >line# line#> ?printable f2key=free 910511jb ) : >line# ( pos --- line# ) c/l / ; ( convert a character position to a line number ) : line#> ( line# --- pos ) c/l * ; ( convert a line number to a character position ) : ?printable ( char --- flag ) dup 31 > swap 127 < and ; : f2key ; \ make it whatever you want \ curpos +curpos move-cursor 910509jb ) : curpos ( --- pos ) &cursor @ ; : +curpos ( n --- ) &cursor +! curpos 0 max \ and do bounds checking [ c/scr 1- ] literal \ char per screen - 1 min &cursor ! ; \ always valid : move-cursor ( n --- ) +curpos \ move the cursor curpos c/l /mod \ raw x y %y-off + swap \ add in y offset %x-off + swap \ add in x offset xycur ; \ and move there