Skip to main content

8. Encoding of Terminal Modes

8. Encoding of Terminal Modes

All encoded terminal modes (as passed in a pty request) are encoded into a byte stream. It is intended that the coding be portable across different environments. The stream consists of opcode-argument pairs wherein the opcode is a byte value. Opcodes 1 to 159 have a single uint32 argument. Opcodes 160 to 255 are not yet defined, and cause parsing to stop (they should only be used after any other data). The stream is terminated by opcode TTY_OP_END (0x00).

The client SHOULD put any modes it knows about in the stream, and the server MAY ignore any modes it does not know about. This allows some degree of machine-independence, at least between systems that use a POSIX-like tty interface. The protocol can support other systems as well, but the client may need to fill reasonable values for a number of parameters so the server pty gets set to a reasonable mode (the server leaves all unspecified mode bits in their default values, and only some combinations make sense).

The naming of opcode values mostly follows the POSIX terminal mode flags. The following opcode values have been defined. Note that the values given below are in decimal format for readability, but they are actually byte values.

opcodemnemonicdescription
0TTY_OP_ENDIndicates end of options.
1VINTRInterrupt character; 255 if none. Similarly for the other characters. Not all of these characters are supported on all systems.
2VQUITThe quit character (sends SIGQUIT signal on POSIX systems).
3VERASEErase the character to left of the cursor.
4VKILLKill the current input line.
5VEOFEnd-of-file character (sends EOF from the terminal).
6VEOLEnd-of-line character in addition to carriage return and/or linefeed.
7VEOL2Additional end-of-line character.
8VSTARTContinues paused output (normally control-Q).
9VSTOPPauses output (normally control-S).
10VSUSPSuspends the current program.
11VDSUSPAnother suspend character.
12VREPRINTReprints the current input line.
13VWERASEErases a word left of cursor.
14VLNEXTEnter the next character typed literally, even if it is a special character
15VFLUSHCharacter to flush output.
16VSWTCHSwitch to a different shell layer.
17VSTATUSPrints system status line (load, command, pid, etc).
18VDISCARDToggles the flushing of terminal output.
30IGNPARThe ignore parity flag. The parameter SHOULD be 0 if this flag is FALSE, and 1 if it is TRUE.
31PARMRKMark parity and framing errors.
32INPCKEnable checking of parity errors.
33ISTRIPStrip 8th bit off characters.
34INLCRMap NL into CR on input.
35IGNCRIgnore CR on input.
36ICRNLMap CR to NL on input.
37IUCLCTranslate uppercase characters to lowercase.
38IXONEnable output flow control.
39IXANYAny char will restart after stop.
40IXOFFEnable input flow control.
41IMAXBELRing bell on input queue full.
50ISIGEnable signals INTR, QUIT, [D]SUSP.
51ICANONCanonicalize input lines.
52XCASEEnable input and output of uppercase characters by preceding their lowercase equivalents with "\".
53ECHOEnable echoing.
54ECHOEVisually erase chars.
55ECHOKKill character discards current line.
56ECHONLEcho NL even if ECHO is off.
57NOFLSHDon't flush after interrupt.
58TOSTOPStop background jobs from output.
59IEXTENEnable extensions.
60ECHOCTLEcho control characters as ^(Char).
61ECHOKEVisual erase for line kill.
62PENDINRetype pending input.
70OPOSTEnable output processing.
71OLCUCConvert lowercase to uppercase.
72ONLCRMap NL to CR-NL.
73OCRNLTranslate carriage return to newline (output).
74ONOCRTranslate newline to carriage return-newline (output).
75ONLRETNewline performs a carriage return (output).
90CS77 bit mode.
91CS88 bit mode.
92PARENBParity enable.
93PARODDOdd parity, else even.
128TTY_OP_ISPEEDSpecifies the input baud rate in bits per second.
129TTY_OP_OSPEEDSpecifies the output baud rate in bits per second.