In video terminals, like the VT100, can control characters and escape sequences only be sent by an application from the host computer to the terminal? Or can they also be sent directly by the user from the keyboard to the terminal? That is, the user controlling the terminal from the keyboard, rather than an application controlling the terminal from the host computer?
I'm trying to understand how video terminals worked by the example of the VT100 family.
I found the following diagram of a VT102 in the VT102 user guide (Figure 1-1).
I assume that on the computer-side of the communication line, there is a driver for this type of terminal, and behind the driver there is an application that reads its input from the terminal and writes its output to the terminal (through the driver). This application might be a shell, or any other application that needs to get input from the user and/or show output to the user.
What I understood so far:
- When a user of the terminal types a character on the keyboard, this character is immediately transmitted to the computer (i.e. the VT100 family uses character-at-a-time mode, there is no local processing of characters entered by the user).
- The receiving application on the computer can then read this character from the terminal driver and do with it whatever it has to do with it.
- Every character that the writes to its output (which is the terminal driver) is sent to the terminal where it is displayed on the screen (except control characters and escape sequences, see below).
- If the application-specific purpose of a character sent from the terminal to the application is such that the user should see it on the screen, then the application must send this character back to the terminal so that it gets displayed on the terminal screen. That is, the VT100 family uses, in most cases, no local echo However, for the VT102, local echo is a setting that can be enabled, see here. This becomes obvious if the application on the computer is something like vi. There, not all characters that the user types must appear on the screen. In particular, characters typed in command mode must not be displayed, whereas characters typed in insert mode must be displayed. This modes are application-specific and neither the terminal nor the terminal driver could know if a given typed character should be displayed or not. So, in these cases, it must be the application that controls the display of user-typed characters.
First of all, are these assumptions correct?
Now to the question. The terminal understands and interprets certain control characters and escape sequences that can be sent from the computer to the terminal. Each of them has an associated control function (e.g. move the cursor on the terminal screen). When the terminal receives such a control character or escape sequence, it does not display it, but executes the associated control function. This stands in contrast to the display characters (non-control characters and not part of an escape sequence) which the terminal just displays on the screen when it receives them.
Control characters, escape sequences, and display characters can be intermixed in any way (there is only a single transmission line from the computer to the terminal anyway). All the control characters and escape sequences that the VT102 understands are explained in the Received Character Processing section of the VT102 user guide.
Control characters are ASCII control characters. The set of control characters understood by the VT10, including the associated control functions, is listed here.
Escape sequences are sequences of characters that start with a special "escape character". The escape sequences understood by the VT102 are the ANSI escape sequences, and they are described in the Escape and Control Sequences section of the VT102 user guide. They always start with the ESC character followed by some other characters.
Control functions associated with VT102 control characters and escape sequences include positioning the cursor on the screen, deleting text on the screen, and setting display attributes (like text colour or font style). This allows applications to control what the user sees on the terminal screen (for example, vi redraws the entire terminal screen when it is started).
Now, my question is, are these control characters and escape sequences only meant to be sent from the application to the terminal? Or is there a way that a user enters them directly into the terminal, e.g. via the keyboard?
The Transmitted Characters section of the VT102 user guide describes all the characters that can be generated with the keyboard. They include control characters and some escape sequences. Are all these characters always sent to the computer without interpretation by the terminal?
For example, if the user hits the ← cursor key, the VT102 user guide says here that this generates the
ESC [ D escape sequence. This is the ANSI escape sequence to move the cursor one position back (see here). So, is this escape sequence still sent to the application rather than being interpreted by the terminal? And then the application interprets it and has to send something back to take an appropriate action on the terminal (probably the
ESC [ D again)?
Or is there a set of control characters or escape sequences that the terminal directly interprets when the user types them on the keyboard (maybe a reduced, different set)?
This is a diagram of the VT102 in off-line mode (i.e. when not connected to a computer), see here:
This makes it obvious that in off-line mode anything typed on the keyboard is directly re-routed to the receiver, and thus probably treated as if it would come from the computer.
My question was if in on-line mode (see diagram above) any control characters pressed on the keyboard are directly interpreted by the terminal rather than being sent to the computer?