The Euphoria Editor
After any error, just type ed, and you'll be placed in the editor, at the line and column where the error was detected. The error message will be at the top of your screen. Euphoria-related files are displayed in color. Other text files are in mono. You'll know that you have misspelled something when the color does not change as you expect. Keywords are blue. Names of routines that are built in to the interpreter appear in magenta. Strings are green, comments are red, most other text is black. Balanced brackets (on the same line) have the same color. You can change these colors as well as several other parameters of ed. See "user-modifiable parameters" near the top of ed.ex. The arrow keys move the cursor left, right, up or down. Most other characters are immediately inserted into the file. In Windows, you can "associate" various types of files with ed.bat. You will then be put into ed when you double-click on these types of files - e.g. .e, .pro, .doc etc. Main Euphoria files ending in .ex (.exw) might better be associated with ex.exe (exw.exe). ed is a multi-file/multi-window editor. Esc c will split your screen so you can view and edit up to 10 files simultaneously, with cutting and pasting between them. You can also use multiple edit windows to view and edit different parts of a single file.
Some keys do not work in a Linux text console, and some keys do not work in an xterm under X windows. Alternate keys have been provided.
Press and release the Esc key, then press one of the following keys:
The Esc n, Esc d, Esc r and Esc f commands prompt you to enter a string. You can recall and edit these strings just as you would at the DOS or Linux command line. Type up-arrow or down-arrow to cycle through strings that you previously entered for a given command, then use left-arrow, right-arrow and the delete key to edit the strings. Press Enter to submit the string.
When you control-Delete (or control-D) a series of consecutive lines, or Delete a series of consecutive characters, you create a "kill-buffer" containing what you just deleted. This kill-buffer can be re-inserted by moving the cursor and then pressing Insert. A new kill-buffer is started, and the old buffer is lost, each time you move away and start deleting somewhere else. For example, cut a series of lines with control-Delete. Then move the cursor to where you want to paste the lines and press Insert. If you want to copy the lines, without destroying the original text, first control-Delete them, then immediately press Insert to re-insert them. Then move somewhere else and press Insert to insert them again, as many times as you like. You can also Delete a series of individual characters, move the cursor, and then paste the deleted characters somewhere else. Immediately press Insert after deleting if you want to copy without removing the original characters. Once you have a kill-buffer, you can type Esc n to read in a new file, or you can press an F-key to select a new edit window. You can then insert your kill-buffer.
The standard tab width is 8 spaces. The editor assumes tab=8 for most files. However, it is more convenient when editing a program for a tab to equal the amount of space that you like to indent. Therefore you will find that tabs are set to 4 when you edit Euphoria files (or .c, or .h or .bas files). The editor converts from tab=8 to tab=4 when reading your program file, and converts back to tab=8 when you save the file. Thus your file remains compatible with the tab=8 world, e.g. MS-DOS PRINT, EDIT, etc. If you would like to choose a different number of spaces to indent, change the line at the top of ed.ex that says "constant PROG_INDENT = 4".
Lines that extend beyond the right edge of the screen are marked with an inverse video character in the 80th column. This warns you that there is more text "out there" that you can't see. You can move the cursor beyond the 80th column. The screen will scroll left or right so the cursor position is always visible.
Like any Euphoria program, ed can use extended memory. It will edit files that are much larger than what MS-DOS EDIT or Windows Notepad can handle. With a huge file, inserting or deleting a line near the beginning of the file might take several seconds, due to intense swapping activity. Other operations should be reasonably quick.
ed is designed for editing pure text files, although you can use it to view other files. As ed reads in a file, it replaces certain non-printable characters (less than ASCII 14) with ASCII 254 - small square. If you try to save a non-text file you will be warned about this. (MS-DOS EDIT will quietly corrupt a non-text file - do not save!). Since ed opens all files as "text" files, the control-z character (26) will appear to be the end of the file.
You can edit existing files that have pathnames with long names in them, and the full file name will be preserved. However in this release ed will not create new files with long names. The name will be truncated to the standard DOS 8.3 length.
The end-of-line terminator on Linux is simply \n. On DOS and Windows, text files have lines ending with \r\n. If you copy a DOS or Windows file to Linux and try to modify it, ed will give you a choice of either keeping the \r\n terminators, or saving the file with \n terminators.
The complete source code to this editor is in bin\ed.ex and bin\syncolor.e. You are welcome to make improvements. There is a section at the top of ed.ex containing "user-modifiable" configuration parameters that you can adjust. The colors and the cursor size may need adjusting for some operating environments.
ed runs best with ex.exe or exu, but will also run with exw.exe.
|