text
stringlengths
0
99.6k
0> ( utilities -- [line] .line list sdbjun85)
1>
2> vocabulary editor
3>
4> : (line) printing? @ if cmdoff then block swap
5> c/l * + c/l printing? @ if #lp (cmdout) drop then ;
6>
7> : .line (line) -trailing type ;
8>
9> : list decimal cr dup scr !
10> ." scr #" u. 16 0
11> do cr i 2 .r ." > " i scr @
12> .line ?terminal ?leave
13> loop cr editor ;
14>
15>
The actual screen editing functions are shown below. You will need to add PL (for Put Line) , SLINE (Screen Line) and the words 0> 1> etc. created by SLINE to this screen. PL simply accepts a line of input from the terminal, and moves it to the insert buffer and to the appropriate spot in the appropriate buffer. SLINE is used to define the numbers displayed by LIST as actual forth words, which call PL with the proper line number.
scr #41
0> ( starting forth editor -- r p sdbmay85)
1>
2> : (r) >line# ibuf 1+ swap >move ;
3>
4> : p 5e text ibuf bufmove (r) ;
5>
6> // following words add fullscreen editing.
7> : pl c/l * r# ! 0 text pad c@ 0= if ibuf 55 blank then
8> ibuf bufmove (r) quit ;
9> : sline create c, does> c@ pl ;
10>
11> 0 sline 0> 1 sline 1> 2 sline 2> 3 sline 3>
12> 4 sline 4> 5 sline 5> 6 sline 6> 7 sline 7>
13> 8 sline 8> 9 sline 9> 0a sline 10> 0b sline 11>
14> 0c sline 12> 0d sline 13> 0e sline 14> 0f sline 15>
15>
Once you have correctly entered these changes and FLUSHed the buffers, proceed as follows:
FORGET THRU
1 LOAD
This will cause the system to recompile, you will get a few "XXXX already exists" messages. This is normal.
When you get the message "LOCATE ENABLED" the system is recompiled, and the fullscreen editing extensions have been added.
Now do:
DCLOSE
Remove the systems disk, and insert a formatted *program* disk into the drive.
Now type
SAVE-FORTH
you will be prompted for a filename. Give it a unique filename (SAVE-FORTH won't replace any files, unless you are daring, and give it the @0: or @1: prefix.) This will cause the modified forth to be saved to disk.
Using the Editor:
All the old editor commands are still active, in addition, you may now cursor around the screen at will, inserting and deleting as you like. Only two things should be remembered:
1) The line numbers 0> , 1> etc. are now defined as Forth words, and so you must remember to follow each with at least one space. For Example:
0> // this is line 0
not
0>//this is line 0
The character length of each line is still only 64 characters in length. If you type more than that, the line will be truncated. Such is life. You can always LIST the screen (or type the line using XX T ) to check up on things.
I hope this answers the questions on exactly how to do it, and also points out the flexibility and extensibility of Forth. How many other languages let you add fullscreen editing or other features? How many let you do it in less than 15 lines of code?
Goodluck!
SDB
Blazin' Forth Editor
====================
Line Commands
=============
( Note: _ represents a blank, __ represents two blanks, etc. )
T (n -- ) Types the line
P ( -- ) Copies the given string into the insert buffer, then
P__ or puts a copy of the insert buffer in the current line.
P xxx
U ( -- ) Copies the given string into the insert buffer, then puts
U__ or a copy of the insert buffer under the current line.
U xxx
M (block line --) Copies the current line into the insert buffer
and moves a copy of the insert buffer into the line under
the specified line in the destination block.