Thoughts about a local HybridEditor for Forth on a Microcontroller
This is something like thoughts and not a completed project.
Some time ago several people in this forum stated, that it would be good to have a self-hosted system for P2. - Actually with Tachyon we have got a compiler and an assembler and an operating system. Nevertheless I found myself using an editor on my PC instead of a local editor. The host is connected to Tera Term running on a PC. I use Notepad++ with syntax highlighting, code folding and with a function list (which is a word-list here) for forth source code. And this editor is just too good in comparison to the very simple "Starting Forth Line Editor" or a simple text editor http://www.murphywong.net/hello/lf.htm.
So I have been asking myself, how could an editor be done with forth, that is still simple and compact (Notepad++.exe has 5.9MegaBytes.....), but good enough, that it would be attractive to use it instead of Notepad++ or similar editors.
The benefit should be, that iterative interactive testing of single words - which is the strong side of forth- would be better supported.
After some thinking about these features "syntax highlighting, code folding, function list" I came to the conclusion, that similar things should be possible with a forth block editor but with additional information displayed together with the block screen. Monitors are bigger nowadays. The active block screen can be seen as the unfolded part of the text. The source code is divided into consecutive blocks, which build a region of blocks. There is plenty of room for very many source code blocks.
The picture shows the actual state of the "HybridEditor". It consists of 4 parts:
1. A list of the 40 last words of the dictionary. (Starts at the top with "fw2")
2. A list of the first lines of colon-definitions preceded, with the block number of their source code. (starting with "40 sgr") This list is generated scanning the region of blocks and is something like the function list or the folded part of the text.
3. The screen listing of the active block number 41 with syntax highlight.
4. A line editor with the active line number 6 at the bottom.
TeraTerm allows to use the mouse to copy text, which can be pasted at the cursor position. No cursor movement with the mouse here.
The line editor can be entered and left easily. Then the interactive environment can be used for additional editor commands like "find" or to save or compile the code.
At the moment the editor has about 500 lines of source code.
Comments, ideas, suggestions?