Suspending, Aborting, Shelling Out and Resizing
Two Special Keys
Two keys generate signals which trigger special actions within ivi
.
<CTRL a> is the Suspend key; <CTRL _ > (or perhaps <CTRL DEL>, depending on your keyboard) is the Abort key.
If ivi
is running under the control of a "driver program", these keys affect the driver program, suspending or killing it, and returning control to the keyboard. (See ivi
Functions, etc.)
If ivi
is under keyboard control, the keys apply directly to ivi
.
The Suspend key is a hangover from earlier times. It puts ivi
into the background, and returns the user to the shell from which ivi
was called. This allows a user to suspend the editor to carry out some other activity. In a windowing system, the user can simply open another window instead.
The shell command:
fg
restores ivi
back to the foreground, and regenerates the display.
The Abort key allows ivi
to recover from several damaging activities. Basically, it:
- removes all pending characters from the input buffer,
- clears the function-stack, and
- sets the abort flag.
In the Miscellanea webpage, we have noted the annoying phenomenon of excessive type-ahead, where many repeated operations may be queued if the time taken complete an operation far exceeds the repetition time of the keys. (a) corrects this by discarding queued operations. (b) caters for the possibility that an ivi
function or procedure has entered an endless loop. Clearing the function-stack causes the offending function or procedure to terminate. (c) is another feature which may have outlived its usefulness. In days gone by, certain activities, such as FEtching or SOrting a very large file, could take many minutes to complete. These operations have been written to terminate quickly but gracefully if the abort flag becomes set. (An aborted SOrt, for instance, retains all the lines of the original, but these are only partially sorted; an aborted FEtch correctly fetches part of the file.) A user who doesn't want to wait for a long operation to be completed can therefore terminate it using the Abort key. Current computers, however, are fast enough that this problem rarely seems to arise.
In some instances, the Abort key may leave the display in an incorrect state or the text cursor in the wrong place. A note on recovery will be found below.
Note that, unlike the ivi
operation keys, these keys are set up at entry to ivi
, and cannot be changed or disabled by the user.
Shelling Out
Command: UNix shell, SHell
Purpose: Spawn a shell and execute a UNIX (or DOS) command within it
Format: UN <string> or SH <string>
Parameter: The two commands are the same. They have two cases. If the parameter <string> is present, this is the command to be executed within the shell. The screen is cleared, the command is carried out, and its output (if any) is written to the screen. The system then prompts for a <RETURN> to get you back to ivi
.
If <string> is omitted, an interactive shell is spawned, and the user can enter commands at the keyboard. The shell command:
exit
then gets you back to ivi
.
Note that <string> cannot contain the symbol | .
Earlier we described the Suspend key <CTRL A>, which suspends ivi
, putting it into the "background" and re-entering a UNIX shell. Superficially, this appears to be same as UN with no parameter, but there is a subtle difference. <CTRL A> re-enters the shell from which ivi
was called; UN enters a subshell of ivi
, which inherits some of ivi
's environment. If, for example, the file directory has been changed within ivi
, the UN shell will be in the new directory. The shell re-entered by <CTRL A> is still in the working directory from which ivi
was called. For most users, the distinction will be irrelevant.
Examples:
UN ls - view the current directory. (This, incidentally, is how the command DIrectory is implemented.)
UN ls >tmp - write the current directory to file tmp, whence it can be FEtched to the corefile.
But not UN cd fred (change the current directory to fred). This changes the working directory in the subshell, but it reverts to the former value when the shell is closed, and thus has no effect. Instead you must use the CDirectory command.
Window Resizing
In the various operating systems, the window running ivi
can be resized using the mouse buttons. This is not advisable, since it risks leaving the ivi
display in a strange state. Recovery from this is described below. If you do persist in trying this, remember that the layout of the ivi
display requires that there should always be more than 80 columns and more than 5 lines.
Recovery
Some activities, like resizing the window or using the Abort key, may leave the display in an incorrect state or the text cursor in the wrong place. This can also occur if a system message is broadcast to the window running ivi
. A procedure exists which tries to re-create the correct display. This may be called automatically by some activities, or explicitly using the GEnerate command.
Command: GEnerate display
Purpose: Re-create the screen display
Format: GE
The GEnerate display command re-creates the screen display if it becomes corrupted, for example by system messages broadcast to the terminal, or some other means. You can, of course, still enter COMMAND mode to type the command even if the screen is in a mess.
Activities which call the underlying procedure automatically may leave the cursor incorrectly positioned. The next keystroke should correct it, but if this is a typed character, it may be displayed in the wrong place. No harm is done. The stored text will still be correct, and an explicit GE should put things right.
By the way, if you insist on resizing the window or using the Abort key while part way through entering a command, the automatic GE may not be able to redisplay the command line, though the existing characters are still there in spirit.
Death and Postmortem Recovery
Many parts of ivi
have been in constant use for almost 40 years. Others, especially the newer features of vinci
, have been less thoroughly exercised. The possibility of internal loops or even crashes cannot be ruled out.
Note that the Abort key does not abort ivi
itself, and indeed no interrupt key is provided for this purpose. If ivi
or vinci
should enter an infinite loop, it must be killed from another window or by using the Suspend key and the UNIX kill command.
At start-up, ivi
alters the some of the properties of the window in which it is running, especially the actions of certain keys. On normal exit, it restores these to their values at start-up. If, however, ivi
is killed or crashes, it has no opportunity to do this, and the window may be left in a bad state. In particular, it may not be echoing UNIX commands to the screen.
To correct this, first note that the <RETURN> key may no longer serve to terminate UNIX commands. The <LINEFEED> or <CTRL J> key, however, should still do so. Enter this to eliminate any residual characters in the UNIX command buffer. Now enter (without seeing an echo):
reset<LINEFEED>
This should restore the echo, and
stty sane<LINEFEED>
will return the keys to their UNIX default actions. (Unfortunately, if you have reassigned UNIX keys you will have to do this again.)
Operation: Dump core
Purpose: Create a file containing a dump of part of the corefile structure
Default Key: <CTRL ]>
Operation Number: 38
This is for debugging purposes only. If you insist on trying it, the file is called test.file. The operation contaminates the display with a message, but this can be corrected using the GEnerate display command.