_edit Utility - Program Editor

Syntax

call "_edit"

Description

The _edit utility calls a full-screen program editor. Though the traditional EDIT verb exists, _edit is an alternative. With _edit the program lines that surround the line to be edited are visible.

The editor uses a combination of editor functions and the !EDIT global string to map the editor functions to keys on the keyboard. (See the STBL() function in the Commands Manual to change !EDIT (!EDIT is case sensitive.) The editor functions are identified in the !EDIT string by hexadecimal codes. Execute A$=STBL("!EDIT") and PRINT HTA(A$) to see how editor functions are mapped to the keyboard.

!EDIT is comprised of two-character substrings. Beginning at position one of the !EDIT string, the substrings consist of a keyboard character, followed by its corresponding editor function code. For example, the default keyboard character for editor function $44$ is $08$, which is the backspace or ^H (Control, H) character.

Default Key Assignments

A set of default keys for each editor function are associated with the editor. On first invocation of the editor, _edit searches the !EDIT global string to determine if function $3F$ has been assigned a keyboard control character. If it has not, it is assigned ^Y by default. The editor then determines if there are any editor functions not represented in the !EDIT string, and if the editor's default key assignment has also not been assigned. If both these criteria are met, the editor assigns its default control character to that function.

The following table lists editor functions and their corresponding default control character assignments. These assignments are only made if the function is not already defined in !EDIT, and the control character is not being used for a different edit function.

Editor Function

Key Assignment

Call Hotkey Menu ($3F$)

^Y ($19$)

Left ($40$)

^] ($1D$)

Right ($41$)

^\ ($1C$)

Up ($42$)

^^ ($1E$)

Down ($43$)

^_ ($1F$)

Backspace ($44$)

^H ($08$)

Restore Line ($45$)

^[ ($1B$) - Escape

Toggle Input Mode ($46$)

^T ($14$) - (Type over/Insert)

Insert Space ($47$)

^E ($05$)

Delete Char. Right ($48$)

^X ($18$)

Tab ($49$)

^I ($09$)

Backtab ($4A$)

^B ($02$)

Clear to EOL ($4B$)

^W ($17$)

Beginning of Line ($4C$)

^A ($01$)

End of Line ($4D$)

^Z ($1A$)

Insert Line ($4E$)

^O ($0F$)

Delete Line ($4F$)

^D ($04$)

Page Down ($50$)

^F ($06$)

Page Up ($51$)

^U ($15$)

Refresh Screen ($52$)

^R ($12$)

Line Call ($65$)

^G ($07$)

Key Repeat ($66$)

^N ($0E$)

Print ($67$)

^P ($10$)

Repeat Last ($68$)

^@ ($00$)

Line Join ($69$)

^V ($16$)

Carriage Return ($70$)

^M ($0D$)

Predefined Error Function Codes

PRO/5 has a set of predefined editor function codes that the verbs INPUTE and EDIT, and _edit use. _edit extends these codes because of its requirement to provide more functionality. Below are all the functions and their codes recognized by the _edit utility. Those numbered from $3F$ to $54$ are predefined by PRO/5, all others are extensions.

Code

Name

Description

$3F$

HOTKEY menu

Displays the HOTKEY menu, which provides access to all editor functions that do not have a corresponding key on the keyboard . This function is always mapped to a key on the keyboard.

$40$

Left

Moves the cursor to the left.

$41$

Right

Moves the cursor to the right.

$42$

Up

Moves the cursor up one line.

$43$

Down

Moves the cursor down one line.

$44$

Backspace

At the end of a text line, deletes the character to the left of the cursor before advancing the cursor left one character. In any other position in a text line, it performs identical to the LEFT function and is compatible with the INPUTE and EDIT verbs.

Often the left arrow key transmits a hex 08 code. In this case PRO/5 cannot distinguish between the left arrow key and the backspace key Therefore the left arrow key function as a backspace key.

$45$

Restore Line

Restores the current line to what it was before being executed. If no changes were made to the line, the editor exits.

$46$

Toggle Insert/Overtype Mode

Toggles the input mode of PRO/5 and the editor.

$47$

Insert Space

Inserts blank spaces to the right of the cursor.

$48$

Delete Character Right

Deletes the character the cursor is positioned on.

$49$

Tab

Moves the cursor to the next tab position on the line. When at the right edge of the physical screen, the cursor is positioned on the next line, and the previous line's buffer is executed in the workspace.

$4A$

Backtab

Similar to tab but advances the cursor to the previous tab position.

$4B$

Clear to End of Line

Clear to End of Line. This function clears the line from the cursor position to the end of the line.

$4C$

Beginning of Line

Moves the cursor to the beginning of the line.

$4D$

End of Line

Moves the cursor to the end of the text on the line.

$4E$

Insert Line

Opens a new line above the line where the cursor is and advances the cursor to the beginning of the new line.

$4F$

Delete Line

Deletes the current line.

$50$

Page Down

Moves the cursor to the bottom of the screen and displays the next page of the workspace program, moving to the bottom of the screen.

$51$

Page Up

Moves the cursor to the top of the screen and displays the previous page of the workspace program, moving the to the top of the screen.

$52$

Refresh Screen

Refreshes the current screen.

$53$

Word Right

Not implemented.

$54$

Word Left

Not implemented.

$65$

Line Call

Clears the line or lines specified, according to the following options:

Syntax type

Comments

Example

Single line number or label.

Displays the individual line.

1000

Line number or label followed by a comma.

Displays the lines between the line or label to the end of the program.

setup,

Line number or label followed by a comma, then a dash.

Displays the lines between the line or label to the bottom of the screen.

Line or Label: 100,-

Line number or label, separated by a comma and followed by a line number or label.

Displays all lines with numbers between a range. Program lines cannot be displayed in a reverse order; for example, Line or Label: 1000,100 is illegal.

start,finish

$66$

Key Repeat

Key Repeat requests the number of times to repeat the next key entered. Macros cannot be repeated.

$67$

Print

Prints the program in the workspace after a line number or range is specified.

$68$

Repeat Last

Repeats the last operation. Cannot be used with macros.

$69$

Line Join

Appends a copy of the next displayed program line to the end of the current line. The lines will be separated by a semicolon.

$6A$

Save Program

Saves the current workspace program, requiring a filename. By default this name is taken from the PGM(-1) function call and the current directory.

$6B$

Merge

Calls _merge to merge lines of code into the current workspace program from a subroutine library.

$6C$

Update

Calls _update to allow the updating of program files with a changed subroutine library. This is used when currently editing the library, have just saved it, and would like to perform an update.

$6D$

Search and/or Replace

Prompts the user for a text string to search for and (optionally) replace.

$6E$

Macro Definition

Defines or loads and saves macros to function keys.

$6F$

Exit

Exits the editor.

$70$

Carriage Return

Simulates a carriage return on the current line. If in insert mode, a new line is opened below the current line. The current line's buffer is executed into the workspace.

In addition to the functions listed above, the editor examines a global string called EDITORMACS (note the case). This defines the load sequence for the macros on function keys 1 through 10 when the editor begins. The format of this string is similar to function key loads as defined in the mnemonics 'FL' and 'EL'. That is, the first byte is the key to be loaded, one of $01$ through $0A$. The next byte is the length of the load sequence to follow. This completes the load sequence for the key specified. An example would be:

DUMMY$=STBL("EDITORMACS",$0102FF3F0204$+"REM ")

In this example, EDITORMACS specifies that function key 1 should be loaded with editor function $3F$ (the preceding $FF$ is a control character that indicates to the editor that what follows is an editor function), and function key 2 is loaded with REM. The macro define function ($6E$). When loading function keys, it optionally set the EDITORMACS global string.

Once the EDITORMACS are set, save it in the file called config.edt by typing:

STRING "config.edt"
OPEN(1) "config.edt"
DUMMY$=HTA (STBL("EDITORMACS"))
PRINT(1) DUMMY$
CLOSE(1)

As long as config.edt can be found using the current prefix, _edit will load EDITORMACS on each invocation. This feature saves time because EDITORMACS is automatically set to a preferred load sequence each time the editor is invoked.

For UNIX: On some systems, hotkeys do not work. Check the stty settings if operations such as CTRL-Y produce unexpected results.

Related Files/Programs

_edit.hlp

_editd.utl

_stdinp.pub

_edita.utl

_edite.utl

_utils.hlp

_editb.utl

_help.pub

 

_editc.utl

_popup.pub

 

See Also

Alphabetical Utilities

Functional Listing of Utilities