HP OpenVMS Systems Documentation
OpenVMS I/O User's Reference Manual
18.104.22.168 Escape and Control Sequences
Escape and control sequences provide additional terminal control notfurnished by the control characters and special keys (seeSection 22.214.171.124). Escape sequences are strings of two or more characters,beginning with the escape character (decimal 27 or hexadecimal 1B),which indicate that control information follows. Many terminals sendand respond to such escape sequences to request special character setsor to indicate the position of a cursor.
The set mode characteristic TT$M_ESCAPE (see Table 5-5) is used tospecify that terminal lines can generate valid escape sequences. Also,the read function modifier IO$M_ESCAPE allows any read operation toterminate on an escape sequence regardless of whether TT$M_ESCAPE isset. If either TT$M_ESCAPE or IO$M_ESCAPE is set, the terminal driververifies the syntax of the escape sequences. The sequence is alwaysconsidered a read function terminator and is returned in the readbuffer; a read buffer can contain other characters that are not part ofan escape sequence, but a complete escape sequence always terminates aread operation. The return information in the read buffer and the I/Ostatus block includes the position and size of the terminating escapesequence in the data record (see Section 5.5).
Any escape sequence received from a terminal is checked for correctsyntax. If the syntax is not correct, SS$_BADESCAPE is returned as thestatus of the I/O. If the escape sequence does not fit in the userbuffer, SS$_PARTESCAPE is returned. If SS$_PARTESCAPE is returned, theapplication program must issue enough single-character read requests,without timeout, to read the remaining characters in the escapesequence, while parsing the syntax of the rest of the escape sequence.Use of the TRM$_ESCTRMOVR item code prevents SS$_PARTESCAPE errors. Nosyntax integrity is guaranteed across read operations. Escape sequencesare never echoed. Valid escape sequences take any of the followingforms (hexadecimal notation):
Three additional escape sequence forms are as follows:
For example, the position cursor control sequence is ESC [ Pl ; Pc Hwhere Pl is the desired line position and Pc is the desired columnposition.
The user guides for the various terminals list valid escape and controlsequences. For example, the VT100 User Guide lists the escapeand control sequences for VT100 terminals.
Section 126.96.36.199 describes control character functions during escapesequences.
Table C-2 lists the valid ANSI and DIGITAL private escape sequencesfor terminals that have the TT2$M_ANSICRT, TT2$M_DECCRT, TT2$M_DECCRT2,TT2$M_AVO, TT2$M_EDIT, and TT2$M_BLOCK characteristics (seeTable 5-6). Table C-2 also lists assumed and selectable ANSImodes and selectable DIGITAL private modes. Only the names of theescape sequences and modes are listed (for more information, refer tothe specific user guide for the various terminals). Unless otherwisenoted, the operation of escape sequences and modes is identical to theparticular terminals that implement these features.
Input (data received) from a terminal is always independent ofconcurrent output (data sent) to a terminal. This feature is calledtype-ahead. Type-ahead is allowed on all terminals, unless explicitlydisabled by the set mode characteristic, inhibit type-ahead(TT$M_NOTYPEAHD; see Table 5-5 and Section 5.4.3).
Data entered at the terminal is retained in the type-ahead buffer untilthe user program issues an I/O request for a read operation. At thattime, the data is transferred to the program buffer and echoed at theterminal where it was typed.
Deferring the echo until the read operation is active allows the userprocess to specify function code modifiers that modify the readoperation. These modifiers can include, for example, noecho(IO$M_NOECHO) and convert lowercase characters to uppercase(IO$M_CVTLOW) (see Table 5-7).
If a read operation is already in progress when the data is typed atthe terminal, the data transfer and echo are immediate.
The action of the driver when the type-ahead buffer fills depends onthe set mode characteristic TT$M_HOSTSYNC (see Table 5-5 andSection 5.4.3). If TT$M_HOSTSYNC is not set, Ctrl/G (bell) is returnedto inform you thatthe type-ahead buffer is full. The buffer must then be emptied, atwhich time a status of SS$_DATAOVERUN is returned.If TT$M_HOSTSYNC is set, the driver stops input by sending a Ctrl/S andthe terminal responds by sending no more characters. These warningoperations begin eight characters before the type-ahead buffer fillsunless the TT2$M_ALTYPEAHD characteristic is set. In that case, thesystem generation parameter TTY_ALTALARM is used. The driver sends aCtrl/Q to restart transmission when the type-ahead buffer emptiescompletely, and the user has posted another READ QIO.
The type-ahead buffer length is variable, with possible values in therange of 0 through 32,767. The length can be set on a systemwide basisthrough use of the system generation parameter TTY_TYPAHDSZ. Terminallines that do a large amount of bulk input should use thecharacteristic TT2$M_ALTYPEAHD, which allows the use of a largertype-ahead buffer specified by the system generation parametersTTY_ALTYPAHD and TTY_ALTALARM. (TTY_ALTYPAHD specifies the total sizeof the alternate type-ahead buffer; TTY_ALTALARM specifies thethreshold at which a Ctrl/S is sent.)
Certain input-intensive applications, such as block mode inputterminals, can take advantage of an optimization in the driver. If aterminal has the characteristic TT2$M_PASTHRU and the read functionIO$M_NOECHO is specified, data is placed directly into the read bufferand thereby eliminates the overhead for moving the data from thetype-ahead buffer.
A line terminator is the control sequence that you type at the terminalto indicate the end of an input line. Optionally, the application canspecify a particular line terminator or class of terminators for readoperations.
Terminators are specified by an argument to the QIO request for a readoperation. By default, they can be any ASCII control character exceptFF, VT, LF, TAB, or BS (see Appendix C). If line editing is enabled,the only terminators are CR, Ctrl/Z, or an escape sequence. Controlkeys that do not have an editing function are nonfunctioning keys. Ifincluded in the request, the argument is a user-selected group ofcharacters (see Section 188.8.131.52).
All characters are 7-bit ASCII characters unless data is input on an8-bit terminal (see Section 5.4.1). The characteristic TT$M_EIGHTBITdetermines whether a terminal uses the 7-bit or 8-bit character set;see Table 5-5. All input characters (except some special keys; seeSection 184.108.40.206) are tested against the selected terminators. The inputis terminated when a match occurs or your input buffer fills.
The terminal driver notifies the job controller to initiate login whenit detects a carriage-return terminator on a line with no currentprocess (provided the line is not a secure server or the type-aheadfeature has not been disabled). A bell character is sent when thenotification occurs. A notification character other than the bellcharacter may be specified by setting the system generation parameterTTY_AUTOCHAR.
The terminal driver supports many special operating modes for terminallines. (Tables 5-5 and 5-6 in Section 5.3 listthese modes.) All special modes are enabled or disabled by the set modeand set characteristics functions (see Section 5.4.3).
Output handling is designed to be very efficient in the terminaldriver. For example, on multiplexers that support both silo and directmemory access (DMA) ouput, the driver considers record size to decidedynamically which mode will result in the least overhead. The blocksize specified by the system generation parameter TTY_DMASIZE is theminimum size block that can be used in a DMA operation.
The terminal driver can execute in either half- or full-duplex mode.These modes describe the terminal driver software, specifically theordering algorithms used to service read and write requests, not theterminal communication lines.
In half-duplex mode, all read and write requests are inserted onto onequeue. The terminal driver removes requests from the head of this queueand executes them one at a time; all requests are executed sequentiallyin the order in which they were issued.
In full-duplex mode, read requests (and all other requests except write requests) are inserted onto one queue and write requests onto another. The existence of two queues allows the driver to recognize the presence of two requests, such as a read request and a write request at the same time. However, the driver does not execute the read request and the write request simultaneously. When it is ready to service a request, the driver decides which request---the read request or the write request---to process next.
The following terms describe the state of a read request:
In the terminal driver, write requests usually have priority. A writerequest can interrupt an active, but not started, read request.
The terminal driver does not start a read request until all outstandingwrites are completed. This means that a read request could be removedfrom the head of the read queue while write requests are outstanding,but the first character is not moved into the read buffer until alloutstanding writes are completed.
Once a read request is started, all write requests are queued until the read completes. However, during a read operation many write requests can be executed before the first input character is entered at the terminal. Terminal lines that have the TT$M_NOECHO characteristic, or read functions that include the IO$M_NOECHO function modifier, do not inhibit write operations in full-duplex mode.
If a write function specifies the IO$M_BREAKTHRU modifier, the writeoperation is not blocked, even by an active read operation.IO$M_BREAKTHRU does not change the order in which write operations arequeued.
When all I/O requests are entered using the Queue I/O Request and Wait($QIOW) system service, there can be only one current I/O request at atime. In this case, the order in which requests are serviced is thesame for both half- and full-duplex modes.
The type-ahead buffer always buffers input data for which there is nocurrent read request, in both half- and full-duplex modes.
By default, output data is subject to formatting by the terminaldriver. This formatting includes actions such as wrapping, tabexpansion, uppercase, and fallback conversions. Applications that donot require formatting of data canwrite with the IO$M_NOFORMAT modifier and thereby reduce overhead.IO$M_NOFORMAT overrides all formatting except fallback translation.Setting the PASTHRU mode (TT2$M_PASTHRU) is equivalent to writing withthe noformat modifier.
Fallback conversions occur regardless of formatting mode.
The SET HOST facility emulates the terminal driver in the way it writesdata to the terminal by stopping the display as soon as the abortcharacter is entered. However, the SET HOST facility behavesdifferently from the terminal driver in that it buffers output datafrom the program that is executing. Occasionally, this causes aperception problem for the user when the program is aborted with aCtrl/C, Ctrl/Y, or an out-of-band abort character. The user expects theprogram to terminate and the display to stop immediately.
When used between two systems, the SET HOST facility consists of twocomponents: RTPAD on the local node and CTDRIVER on the remote node.Both components buffer output data to enhance performance when usingwide area networks. CTDRIVER performs the initial buffering, queues thebuffers for network transfer, and returns a successful write status.The user should note that the local terminal display reflects theoutput of the executing program after the data has been buffered andtransferred over the network---not as the output buffers are filled onthe remote node.
The delay between execution of an application and the display of itsoutput can lead to several anomalies in the effects of Ctrl/C, Ctrl/Y,and out-of-band abort characters.
After you enter an abort character (Ctrl/C, Ctrl/Y, or an out-of-bandabort character) that causes the input or output to be aborted, it ispossible to receive an additional line of output. This occurs when theapplication program calls $QIO (either directly or indirectly throughRMS or language support routines) to output data to a buffer at thesame time the abort character is entered.
When CTDRIVER receives the abort character (Ctrl/C, Ctrl/Y, or anout-of-band abort character) from the network, it flushes the currentoutput buffers and aborts any pending read operations. However, if theapplication program calls $QIO with a write operation when the abortcharacter is entered, the $QIO write data is still buffered and thendisplayed. The data may not be the next output in sequence from theuser's point of view, since all the previous output buffers in CTDRIVERwere flushed and the data in them was not displayed.
When using the terminal driver, the effect of an abort character on thedisplay screen is different. The terminal driver does not buffer outputfrom the application during program execution. If the applicationprogram has just called $QIO with a write operation when the abortcharacter is entered, then the $QIO write data is displayed. Becauseall write operations are sequential and do not complete until theoutput is actually displayed, the additional line displayed is insequence. There is no break in the data. Normally, the user will notnotice that there is an additional line.
For connections between systems, the CTERM protocol allows CTDRIVER tosynchronize with RTPAD before displaying any more data on the terminal.
The abort character AST is delivered after the message describing theaborted read operation has been received. Therefore, the read statusshould be set very shortly after the abort character AST is deliveredto the application. Note, however, these are still two asynchronousevents, and the application must still synchronize with the completingread operation.
CTDRIVER and RTPAD emulate the terminal driver in that the current readoperation and all pending write operations abort when Ctrl/Y isentered. However, the pending write operations also include all thebuffered output that occurred and that would have been output beforethe Ctrl/Y was entered but due to the buffering was not.
The effect of the buffering can be confusing if a Ctrl/Y is enteredwhen a captive command procedure is executing. During execution ofcaptive command procedures, DCL has a Ctrl/Y pending. When this AST isdelivered, DCL only reenables it; no other action is performed. In thatcase, if the program being executed only performs output, it appearsthat the program was aborted by the Ctrl/Y. Actually, the programcompleted execution before the Ctrl/Y was entered, and the Ctrl/Ymerely discarded all the buffered output.
The operating system supports modem control (for example, Bell 103A,Bell 113, or equivalent) for all supported multiplexers in autoanswer,full-duplex mode. The terminal driver does not support half-duplexoperations on modems such as the Bell 202. Also not supported aremodems that use circuit 108/1 (connect data set to line signal) inplace of the data terminal ready (DTR) signal. Most U.S. and Europeanmodems use the data terminal ready signal, which is the signalsupported by the operating system.
Dialup lines with the characteristic TT$M_MODEM are monitoredperiodically to detect a change in the modem carrier signals data setready (DSR), calling indicator (RING), or request to send (RTS). Thesystem generation parameter TTY_SCANDELTA establishes the dialupmonitoring period for multiplexers that do not support modem signaltransition interrupts (see Table 5-1).
If a line's carrier signal is lost, the driver waits 2 seconds for thecarrier signal to return. If bit 0 of the system generation parameterTTY_DIALTYPE is set to 1, the driver does not wait. Bit 0 is 0 bydefault forcountries with Bell System standards, but that bit should be set to 1for countries with International Telegraph and Telephone ConsultativeCommittee (CCITT) standards. If the carrier signal is not detectedduring this time, the line is hung up. The hangup action can signal theowner of the line, through a mailbox message, that the line is nolonger in use. (No dial-in message is sent; the unsolicited charactermessage is sufficient when the first available data is received.) Theline is not available for a minimum of 2 seconds after the hangupsequence begins. The hangup sequence is not reversible. If the linehangs up, all enabled Ctrl/Y and out-of-band ASTs are delivered;the Ctrl/Y AST P2 argument is overwritten with SS$_HANGUP. The I/Ooperation in progress is canceled, and the status value SS$_HANGUP isreturned in the I/O status block. DCL is responsible for processdeletion after Ctrl/Y is delivered. If the process is suspended, DCLcannot run, and therefore deletion cannot occur, until the process isresumed.
For terminals with the TT$M_MODEM characteristic, TT$M_REMOTE reflectsthe state of the carrier signal. TT$M_REMOTE is set when the carriersignal changes from off to on, and cleared when the carrier signal islost.
A line that does not have TT$M_MODEM set does not respond to modemsignals or set the DTR signal. Modem signals can be set and sensedmanually through use of the IO$M_MAINT function modifier (seeSection 220.127.116.11).
The terminal driver default modem protocolmeets the requirements of the United States and of European countries.This protocol is capable of working in automatic answer mode and canalso perform manually dialed outgoing calls. The protocol supports therequirements of most known international telephone networks. Enhancedmodem features are used on multiplexers that support them; processorpolling is not necessary. The protocol also functions in a subset modefor the multiplexers that do not support full modem signals (seeTable 5-1).
Table 5-3 lists the control and data signals used in a full modemcontrol mode configuration (in a two-way simultaneous, symmetricaltransmit mode). Figure 5-1 is a flowchart that shows a typicalsignal sequence for a terminal operation in this mode. The flowchartshows the states that the modem transition code goes through to detectdifferent types of transitions in modem state. These transitions allowthe driver to detect loss of lines that have been idle for severalminutes. Modem states do not affect the ability of the system totransmit characters.
Figure 5-1 Modem Control: Two-Way SimultaneousOperation
Set mode function modifiers are provided to allow a process to activateor deactivate modem control signals (see Section 18.104.22.168).
Bit 1 of the system generation parameter TTY_DIALTYPE enables alternatemodemprotocol on a systemwide basis. If bit 1 is 0 (the default), the RINGsignal is not used. If bit 1 is 1, the modem protocol delays settingthe DTR signal until the RING signal is detected.
Remote terminal connections have a timeout feature for the security ofdialup lines. If no channel is assigned to the port within 30 seconds,or a port with an assigned channel is not allocated, the DTR signal isdropped. Such action prevents an unused terminal from tying up a line.However, there are configurations (such as a printer connected to aremote line) in which the line should not be dropped even though it isnot being used interactively. To bypass the 30-second timeout, set thesystem generation parameter TTY_DIALTYPE to 4. (Note that ifTTY_DIALTYPE is equal to 4, all dialup lines will skip the timeoutwaiting for a channel to be assigned.)
1Multiplexers (All = any supported controller; Full = DZ32,DMF32, DMB32, DMZ32, DHU11, DHV11, and CXY08).