colorforth editor

colorforth keyboard and command line

colorforth uses 27 keys on the PC keyboard.
The four fingers of the left hand are placed on the qwerty keys "ASDF" and are moved up one row or down one row.
The four fingers of the right hand are place on the qwerty keys "JKL;" and are moved up one row or down one row.
The thumb(S) press the qwerty keys "N", "Spacebar", and "Alt"

colorforth keyboard

The default keyboard map for the keys is:

default colorforth keyboard map

The fingers of the left hand are on the "aoeu" keys
The fingers of the right hand are on the "htns" keys.

Qwerty "N" is not programmed,
Spacebar is labeled "9" and invokes the number key function.
Qwerty "Alt" is labeled "x" and invokes the extended key function.

Once you have begun entering characters the keyboard map changes to:

colorforth default keyboard map while entering characters

Qwerty "N" is labeled "X" and will abort word entry and return to the default keyboard map.
Spacebar is labeled "." and enters the word and returns to the default keyboard map.
Qwerty "Alt" is labeled "x" in either of those modes and invokes the extended keyboard map for 23 alternate characters.

alternate extended character colorforth keyboard map

Qwerty "N" is not programmed in this mode.
Qwerty "Alt" returns to the normal keyboard menu.
Spacebar is not shown as programmed, but it will complete entry of a word and return to the normal keyboard menu.

On the normal keyboard map the Spacebar is labeled "9" and invokes number keyboard map in decimal or hex mode Below is the decimal keyboard map.

decimal number entry keyboard map

Qwerty "N" is labeled "-" and enters a negative number.
Spacebar is labeled "a" and returns to the default text keyboard map.
Qwerty "Alt" is labeled "f" and selects the hex keyboard map.

hex number entry keyboard map

Qwerty "N" is labeled "-" and enters a negative number.
Spacebar is labeled "a" and returns to the default text keyboard map.
Qwerty "Alt" is labeled "9" and selects the decimal keyboard map.

When one enters a yellow number on the command line one will see the number that is being entered and will be visible in the stack picture window on the left side of the command line. Text is entered from the right side of the line and each word is executed when a space is entered. When text is entered the number that represents the packed characters in the colorforth word as it is being entered. When the spacebar is pressed colorforth will in the case of number entry leave a number on the stack, or in the case of text entry will attempt to find and execute the word that was typed on the command line.

colorforth source editor

To invoke the editor first enter a block number. Press the spacebar to invoke the number entry keyboard map. If you see a hex number keyboard map press the qwerty "Alt" key labeled "9" to return to decimal entry mode. Move the index finger of the right hand up to the qwerty "U" key, and press the key labeled "1". Move the middle finger of the right hand down one row to the qwerty "," key and press the key labeled "8". Then press the spacebar to put the number "18" on the command line.

The left side of the command line is a stack picture in colorforth. The "18" should the rightmost number showing that it is on top of the parameter stack in colorforth. Because blocks 0-17 are the kernal and font the editor will not edit blocks 0-17.

The normal keyboard map will return and you can type "edit" by pressing down with the middle finger of you left hand for the "e", moving the index finger of the left hand down one row and pressing the "d" key, moving the index finger of the left hand up two rows and pressing the "i" key, the center finger of the right hand pressing the "t" key, and a thumb pressing the spacebar to execute the "edit " command.

You will see the source code to block "18" and the number "18" will be displayed on the left side of the command line as the block being edited. The editor keyboard map is displayed in the lower right part of the screen.

editor keyboard map

editor commands

"S" enter white comments in all caps
"C" enter white comments with the first character capitalized
"t" enter white comments in lower case
"y" enter yellow text or numbers
"r" enter red name
"g" enter green text or numbers
"x" toggle odd/even source/shadow code/comment blocks
"f" repeat 'find'
"j" jump to last edited block
"l" move cursor left
"u" move cursor up, (eight left)
"d" move cursor down, (eight right)
"r" move cursor right
"-" decrement edited block by two
"m" enter magenta variable name
"c" enter cyan text
"+" increment edited block number by two
"X" delete the current word, (cut for paste)
"." exit editor to command line
"i" insert word, (paste from buffer)

cursor control

When the editor is started for the first time the cursor will appear in the upper right corner of the block. If there is text there it will appear on top of the first character. If the cursor is moved to the right of the first word, in the first space after the first word.

colorforth cursor

The cursor resembles a pac-man character poised to munch the word to the left when the "X" (delete word) key is pressed. Strings of text can be cut by repeatedly pressing or holding the "X" key. The cursor can be moved to a different location on that block, or to a different block, and inserted with the "i" key.

Left, Up, Down, and Right keys under the fingers of the right hand move the cursor. The cursor cannot be moved above the top of the screen but it can be moved below the bottom of the screen. If the cursor is not visible hold down the Up key. If it does not appear there may be an error in the editor. Exit the editor with the "." key, and enter a nonsense word like "nth" and the system will show an error on the command line with a "nth?" message. Then type "e " to enter the editor and use the Up key to get the cursor back on the screen.

"l" move cursor left
"u" move cursor up, (eight left)
"d" move cursor down, (eight right)
"r" move cursor right

Note that the Up and Down keys do not make precise up and down movements and only move eight words to the left or right respectively if possible.

Words that have been deleted with the "X" key can be re-inserted with the "i" key after the cursor has been moved. New text in any color can be inserted.

white comment entry

Comments will appear in white when editing and will be ignored by the compiler. Comments may contain any of the normal 24 characters or the 23 extended alternate characters which include the symbols 0-9. Comments can be entered in three ways:

"t" enter white comments in lower case characters.
"S" enter white comments in all capital characters.
"C" enter white comments with the first character capitalized.
When you are in white, comment entry mode, a "9" will appear in the comment entry key menu, and if you press it it will appear to let you enter a number. But numbers are not allowed in comment mode. You must select the "x" extended alternate keyboard menu and use the "0-9" characters, the symbols, in comments.

To exit comment entry mode press the "." key.

yellow text and number entry

Yellow text are words that are interpreted in colorforth when blocks are loaded. Red words are the names of new defined words, they are like the names that follow ":" in traditional Forth. Green words are words being compiled. Magenta words are variables, and cyan words are like "postponed" words in ANS Forth.

Numbers can be entered in green or yellow mode. Numbers can be entered in decimal or hex mode. Hex numbers will appear in a darker green or darker yellow than decimal numbers.

If one intends to enter a number but enters a character string that resembles a number instead it cannot be visually distinguished from a decimal number as it will be the same shade of yellow or green. But when you load the block unless you have actually defined a red word or magenta variable with a name that can be confused for a number, which is generally not a good idea in the first place, you will get a compiler error message that it did not recognize the string (that looked like a number) as a defined name.

There is a Forth wordlist and a macro wordlist in the colorforth compiler and the macro wordlist is searched first durring compilation. Words in the marcro wordlist act like "immediate" word in traditional Forth.

green text and number entry

Green words like "IF" are compiled, but because they are in the macro wordlist and act like immediate words, they are executed at compile time like words written explicity in yellow.

A transistion from green words to yellow words and back to green words is interpreted by the compiler as follows; the transition from green to yellow marks the transition from compilation mode to interpretation mode as would be indicated by the ANS Forth word "[" and the transition from yellow to green is interpreted by the compiler to mean a transition from interpretation mode to compile mode, and the compilation of a literal as would be indicated by the ANS Forth phrase "] LITERAL"

red name entry

When the "r" key is pressed to enter a red word the text for the red name will be aligned on the left side of the screen. A red name is the name of the compiled code that follows it in green. The red name can then be used in green, yellow, cyan or white colors. A call or jump to the word can be compiled with green usage, the word can be interpreted with yellow usage, a defined word can be postponed with cyan usage, and if written in white will always be a comment.

After entering a red word the editor will change the color of the text or numbers being entered into green because the red word is the name of the compiled, green code that follows.

magenta variable name entry

When selecting magenta, and a magenta variable name is added to a block, a green number with the value 0 will be added after the magenta name. The magenta word when executed places the address of the location of the green number on that block on the parameter stack.

cyan entry

Cyan words are like postponed words in ANS Forth.

cut and paste

Cut is performed by the "X" key and paste is performed by the "i" key.

find again

You can exit the editor and find a word in the system by typing the command "find " and then typing the name of the of the word that you want to find and the spacebar.

If the word is found it will take you into the editor with the cursor close to the found word. If you press the "f" key you the editor will take you to the next occurance of the word in the system.

jump

The "j" key jumps between the last two blocks that you edited with the word "edit ". The traditional variable "blk" contains the number of the last block edited with "edit ".

shadow blocks

The "x" key toggles between odd/even blocks while editing. Even numbered blocks are intended for source code and odd numbered blocks are intended for comments. Since odd numbered blocks are not normally compiled and red, yellow, green, cyan, or magenta words on those blocks are intended to be comments only. Those colors may be used for comments on shadow blocks with the understanding that odd numbered blocks are not normally loaded.

two blocks up or two blocks down

The "+" and "-" keys on the editor keyboard map move two blocks up or two blocks down. The editor will not decrement the block number to be edited below 18.

modifying the editor key table

On block 64 a yellow phrase appears just before the red word "fk"

"fk" is the function assigned to the "f" key in the editor keyboard table.

Since "here" in the yellow phrase before the red "fk" is the address of the compiled code for "fk" the yellow phrase "here ekt 22 + !" stores the vector for "fk" into the editor key table (ekt) being used by the editor at an offset of 22 words.

copying blocks

To copy a block first get the block number that you want to copy in the variable "blk". When you edit a block the block number will be left in "blk". The word "copy" takes the destination block number from the stack. Put the destination block number on the stack and type "copy "

If you want to edit the copied block just type "e " as "blk" will now be set to the number of the destination block.

July 20, 2006 Jeff Fox