OpenEuphoria: Euphoria v4.1

# OpenEuphoria Manual

## Euphoria v4.1

routine or constant name search

| Up |  |  | TOC | Index
<< 6 Mini-Guides | < 7.2 EuDOC Source Documentation Tool | Up: 7 Included Tools | 7.4 EuDis, Disassembling Euphoria Code > | 8 API Reference >>

## 7.3 Edx Demonstration Code Editor

### 7.3.1 Introduction

The Euphoria includes a handy, text-mode editor, `edx` that is written completely in Euphoria.

While `edx` is intended as a demonstration program, many people find `edx` convenient for editing and examinng small programs.

### 7.3.2 Summary

Usage:

1. `edx filename`
2. `edx`

After any error, just type `edx` and you will 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 will 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 edx. See user-modifiable parameters near the top of `edx.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 `edx.bat`. You will then be put into edx when you double-click on these types of files -- such as. `.e, .pro, .doc` etc. Main Euphoria files ending in `.ex`, `.exd` or `.exw` might better be associated with `eui.exe`, `euid.exe`, or `euiw.exe`, respectively.

edx is a multi-file and multi-window text-based editor. Esc c will split your screen so you can view and edit up to ten 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.

### 7.3.3 Special Keys

Some PC keys do not work in a Linux or FreeBSD or Windows text console, or in Telnet, and some keys do not work in an xterm under X windows. Alternate keys have been provided. In some cases you might have to edit `edx.ex` to map the desired key to the desired function. For example you may have to use C-t and C-b instead of C-Home and C-End.

Delete | Delete the current character above the cursor
Backspace | Move the cursor to the left and delete a character
C-Delete | Delete the current line (not available on all platforms)
C-d | Delete the current line (same as C-Delete)
Insert | re-insert the preceding series of Deletes before the current line/character
C-Left | Move to the start of the previous word. On Unix use C-l
C-Right | Move to the start of the next word. On Unix use C-r
Home | Move to the beginning of the current line
End | Move to the end of the current line
C-Home | Move to the beginning of the file (euid.exe only, others use C-t
C-End | Move to the end of the file (euid.exe only, others use C-b
PgUp | Move up one screen. On Unix use C-u
PgDn | Move down one screen. On Unix use C-p
F1..F10 | Select a new window. The windows are numbered from top to bottom with the top window on the screen being F1
F12 | User definable key (see `CUSTOM_KEYSTROKES` near top of `ed.ex`. Default action is to insert `--` for a Euphoria comment

### 7.3.4 Escape Commands

Press and release the Esc key, then press one of the following keys:

h | Get help text for the editor, or Euphoria. The screen is split so you can view your program and the help text at the same time.
c | "Clone" the current window, i.e. make a new edit window that is initially viewing the same file at the same position as the current window. The sizes of all windows are adjusted to make room for the new window. You might want to use Esc l to get more lines on the screen. Each window that you create can be scrolled independently and each has its own menu bar. The changes that you make to a file will initially appear only in the current window. When you press an F-key to select a new window, any changes will appear there as well. You can use Esc n to read a new file into any window.
q | Quit (delete) the current window and leave the editor if there are no more windows. You'll be warned if this is the last window used for editing a modified file. Any remaining windows are given more space.
s | Save the file being edited in the current window, then quit the current window as Esc q above.
w | Save the file but do not quit the window.
e | Save the file, and then execute it with `euid`, `euiw` or `eui`. When the program finishes execution you'll hear a beep. Hit Enter to return to the editor. This operation may not work if you are very low on extended memory. You can't supply any command-line arguments to the program.
d | Run an operating system command. After the beep, hit Enter to return to the editor. You could also use this command to edit another file and then return, but Esc c is probably more convenient.
n | Start editing a new file in the current window. Deleted lines/chars and search strings are available for use in the new file. You must type in the path to the new file. Alternatively, you can drag a file name from a Windows file manager window into the console window for `edx`. This will type the full path for you.
f | Find the next occurrence of a string in the current window. When you type in a new string there is an option to "match case" or not. Press y if you require upper/lower case to match. Keep hitting Enter to find subsequent occurrences. Any other key stops the search. To search from the beginning, press C-Home before Esc f. The default string to search for, if you don't type anything, is shown in double quotes.
r | Globally replace one string by another. Operates like Esc f command. Keep hitting Enter to continue replacing. Be careful - there is no way to skip over a possible replacement.
l | Change the number of lines displayed on the screen. Only certain values are allowed, depending on your video card. Many cards will allow 25, 28, 43 and 50 lines. In a Unix text console you're stuck with the number of lines available (usually 25). In a Unix terminal xterm window, `edx` will use the number of lines initially available when `edx` is started up. Changing the size of the window will have no effect after `edx` is started.
m | Show the modifications that you've made so far. The current edit buffer is saved as `editbuff.tmp`, and is compared with the file on disk using the Windows `fc` command, or the Linux/FreeBSD `diff` command. Esc m is very useful when you want to quit the editor, but you can't remember what changes you made, or whether it's ok to save them. It's also useful when you make an editing mistake and you want to see what the original text looked like.
ddd | Move to line number ddd. e.g. Esc 1023 Enter would move to line 1023 in the file.
CR | Esc Carriage-Return, i.e. Esc Enter, will tell you the name of the current file, as well as the line and character position you are on, and whether the file has been modified since the last save. If you press Esc and then change your mind, it is harmless to just hit Enter so you can go back to editing.

### 7.3.5 Recalling Previous Strings

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 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.

### 7.3.6 Cutting and Pasting

When you C-Delete (or C-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 C-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 C-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.

### 7.3.7 Using Tabs

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 four 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.

If you would like to choose a different number of spaces to indent, change the line at the top of `edx.ex` that says "`constant PROG_INDENT = 4`".

### 7.3.8 Long Lines

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 not see. You can move the cursor beyond the 80th column. The screen will scroll left or right so the cursor position is always visible.

### 7.3.9 Maximum File Size

Like any Euphoria program, `edx` can access all the memory on your machine. It can edit huge files, and unless disk swapping occurs, most operations will be very fast.

### 7.3.10 Non-text Files

`edx` is designed for editing pure text files, although you can use it to view other files. As `edx` reads in a file, it replaces certain non-printable characters (less than ASCII 14) with ASCII 254 -- a small square. If you try to save a non-text file you will be warned about this. Since `edx` opens all files as "text" files, a control-z character (26) embedded in a file will appear to `edx` to be the end of the file.

### 7.3.11 Line Terminator

The end-of-line terminator on Unixis simply `\n`. On Windows text files have lines ending with `\r\n`. If you copy a Windows file to Unix and try to modify it, edx will give you a choice of either keeping the `\r\n` terminators, or saving the file with `\n` terminators.

### 7.3.12 Source-Code

The complete source code to this editor is in `bin\edx.ex` and `bin\syncolor.e` . You are welcome to make improvements. There is a section at the top of `edx.ex` containing user-modifiable configuration parameters that you can adjust. The colors and the cursor size may need adjusting for some operating environments.

| Up |  |  | TOC | Index
<< 6 Mini-Guides | < 7.2 EuDOC Source Documentation Tool | Up: 7 Included Tools | 7.4 EuDis, Disassembling Euphoria Code > | 8 API Reference >>