Charley Shattuck's colorForth page

charley@forth.org

Examples of colorForth code and links to other colorForth sites.

Converting colorForth source blocks into html.

readblk.fs Gforth program.
colorforth.css Cascading Style Sheet.
cf2a Bash script.

I've seen two programs on the web to convert colorForth blocks into html for display on the web, using cascading style sheets to determine the font and colors. One is written in C, which I can't really understand,and the other is written in colorForth. I've ported the colorForth version to Gforth so that I can use it from Linux. I've also adapted one of the colorforth.css files from the web to work with the tags produced by this converter, and such that the colors look good when I print them on my inkjet printer, including the yellow. The html files don't work without the colorforth.css file.

I use the script cf2a (ColorForth to Ascii) to convert a colorforth.blk file into html. The parameters are 'block count offset' where 'block' is the first block in the blk file to convert, often 0, the 'count' is how many blocks to convert, and 'offset' is what to label the first block, assuming you started from 0, that is, what block number did it have in colorforth? I'm sure you could adapt this to work in Windows if you wanted to.

My colorForth programs

Extending the colorForth editor

I saw Chuck Moore speak and demo his current version of colorForth at SVFIG's Forth Day on November 19, 2005. He has added some search functions to his editor. I didn't know how to replicate what he has exactly, so I made some changes in my own way. To the main editing screen I've added a row of prompts in the home row of the left hand, namely CNFJ.

The C means change color. This command will act on the word behind the cursor to cycle through the colors white, yellow, and green. Other colors are not affected. This lets me comment out a word for testing, then get it back again with minimal editing.

The F means find. It reads the word behind the cursor, strips the color tag, and stores it is the variable wrd. Then it starts searching at block 18 up to block 150. If it finds the word it will point the editor and cursor at what it's found. The N key means next, and searches from the current point to find the next occurance of wrd. The J key jumps back the the block you started from, that is, the one you got to by typing edit. Since the color info is stripped from the word, you find every instance of the word no matter what color. This usually results in finding the red definition first, and uses of the word in yellow or green after.

I had to do some guessing and dumping to find the addresses of some variables like blk, curs, and cad, as well as the locations of the editors jump tables so I could patch them. For me this was easier than learning how to use a conventional assembler to make the changes.

editor_additions.blk Get the colorForth blocks.
editor_additions.html View the source code.

Extending the colorForth editor, only simpler

After using the editor changes above for awhile I realized that it could be done less obtrusively if I avoided the patching and just ran the words from the command line. Also, I figured out what was wrong with @+ using the a register (EDX). A number of words in the kernel clobber the EDX register, including swap and jump. I decided to use the EBX register instead and call it b. I searched the source code and found that EBX is only used during boot. Using the new code you start the editor with the word ed, which copies blk into scr. If you want to return to this screen, from the command line run r. If you want to find the source code for a word, place the cursor just past the word, exit the editor and run find. To find more instances of the same word, exit the editor again and run f. To change the color of the word under the cursor, exit the editor and run cc, for Change Color. This will only work on white, yellow, or green words, not numbers or variables, and no caps. Cyan is also ignored.

Note that ed is defined on screen 64 as '66 load ;'. I intend to name my additions on screen 64 as I make them. Screen 18 has been edited to load screen 64.

editor_additions_2.blk Get the colorForth blocks.
editor_additions_2.html View the source code.

Links to other colorForth sites

Chuck Moore www.colorforth.com

Jeff Fox www.ultratechnology.com

Raymond A. St. Marie II colorforth.info

Updated December 3, 2005.