• Aucun résultat trouvé

ED, the System Screen Editor

Dans le document Lt QU (Page 85-88)

The screen editor program, ED, found in the c directory of the Workbench disk, can be used like any CLI command program.

But ED is not really a DOS file-management command pro gram. Rather, it's a full-screen text editor which can be used to create a text file or edit an existing one. It differs from the other text editor program included on the Workbench disk, EDIT, in a variety of ways. EDIT is a line-oriented editor, which means that you must first select the line you want to change. ED, however, is a screen-oriented editor, which dis plays a whole screen of text at a time and lets you move the cursor around the screen, adding or deleting text as you see fit. While EDIT can be used to alter files which contain binary code, ED is designed to edit text-only files. And, finally, ED files always end with a linefeed character, which ED adds if it doesn't find one already present.

To start ED, type ED, followed by the name of the file you wish to edit. If the filename doesn't describe an existing file, ED assumes that you want to create a new file. To exit the ED program, type ESC-Q simply to quit or ESC-X to save the current file and exit.

ED starts with a maximum workspace of 40,000 charac ters. Unless you change the size of the workspace, you're lim ited to editing files of that size. To change the size of the workspace, use the keyword SIZE on the command line which you use to run ED, followed by the number of characters you want in the workspace. For example, entering the command ED Windbag SIZE 100000 lets you edit a file called Windbag which can contain up to 100,000 characters. It's a good idea always to specify a size somewhat greater than the exact size of the file.

There are two ways of issuing commands to ED—immedi ate mode and command mode. In immediate mode, you give ED its commands by pressing nonprinting key combinations. In ex tended command mode, you first type the ESC character, which places your cursor on the command line at the bottom of the screen. You may then type in one or more command strings.

The command is not executed until you press RETURN.

ED, the System Screen Editor

LJ

U

Immediate Mode [_J

The ED program starts in immediate mode. Here, the charac

ters you type are inserted into the text document. To edit, just -move the cursor to the appropriate place and either erase exist- \^J ing text or add new text. In addition, there are a number of

control commands which help in editing. These commands are executed by holding down the CTRL key, then pressing an-other key. (The notation CTRL-x will be used to refer to these commands. This indicates that you're to hold down CTRL,

and press the key specified by x.) All CTRL character com- ^^

mands are executed as soon as you press the key combination.

Cursor Commands

The cursor is a colored block which indicates the position where additional characters will enter the text buffer. If you're using the default set of colors, it appears as an orange block highlighting the current character. You can move the cursor in any direction by pressing one of the cursor arrow keys to the right of the RETURN key. If there's more text in the buffer than appears on the screen, moving the cursor to any edge of the screen and pressing the corresponding cursor arrow key shifts all text (scrolls) to show part of the hidden text. For ex ample, if you move the cursor to the bottom line of the first screen of a long document, then press the down-arrow key, the cursor moves down to the next line and reveals the hidden first line of the next screen. What was formerly the top line

scrolls up and out of sight. By using the down and up arrows, - _ you can move forward and backward through the text file.

Other immediate commands allow you to move the cursor

in larger increments. The CTRL-T combination moves the - __

cursor right to the first character of the next word. CTRL-R moves the cursor back to the space at the end of the previous word. CTRL-] moves the cursor to the end of the current line, scrolling the screen if the line is longer than the screen width.

If the cursor is already at the end of the line, CTRL-] moves it back to the beginning of the line. If you press CTRL-] a num ber of times, the cursor alternates between the first and last characters of the line. Likewise, CTRL-E moves the cursor to the beginning of the first line on the screen. If, however, the cursor is already at the start of the first line, CTRL-E moves it to the end of the last line on the screen.

n n n n

ED, the System Screen Editor

The scroll commands don't change the absolute position of the cursor, but rather move the text itself. CTRL-U scrolls the screen up, which appears to make the cursor move down toward the end of the document. CTRL-D scrolls the screen down, which in effect moves the cursor toward the beginning of the document. Either command causes the whole screen to be redrawn from the top, making the scrolling action rather slow.

Note that in ED, the TAB key is strictly a cursor move ment key. When you press TAB (or CTRL-I), the cursor moves to the next TAB position, which is one greater than an even multiple of the TAB setting. For example, if you're using the default TAB setting 3, the TAB key moves the cursor from col umn 1 (the left edge of the screen) to column 4, then column 7, column 10, column 13, and so on. You can change the size of the TAB stops with the extended command ST (see below).

Unlike some editors, ED doesn't insert characters into the text when you press TAB. The TAB key leaves neither a TAB character nor spaces in the text, though if it passes over a blank portion of the line, the space characters it bypasses re main in the text. Note also that if you enter a text file which contains TAB characters into ED, ED replaces each with a number of spaces.

Character Deletion/Insertion

When you've moved the cursor to the text location you want to edit, there are several immediate mode commands which you can use to delete or insert text. The BACK SPACE key (or CTRL-H) moves the cursor one character to the left, deleting the character. The DEL key deletes the character under the cursor and moves the text to the right one position to the left.

You can also delete characters in larger chunks. The CTRL-O command's actions depend on whether the cursor rests on a character or a space. If the cursor is on a space, CTRL-O deletes all spaces it finds until the first character of the next word. Otherwise, CTRL-O deletes the current charac ter and all characters it finds until the next space between words. Thus, CTRL-O can be used alternatively to delete whole words or the spaces between words. CTRL-Y deletes everything from the current character position to the end of the line. CTRL-B deletes the entire current line, regardless of the cursor position.

ED, the System Screen Editor

LJ

Unlike most screen editors, ED doesn't let you delete the I I

Dans le document Lt QU (Page 85-88)