The term 'terminal' is often used to refer to a display device with a 
 video screen, but terminals are really a certain class of peripherial 
 devices, including in addition to video terminals also printers 
 (sometimes called hardcopy terminals), plotters, etc. 

 Terminal is a short for 'terminal equipment' - everything connected 
 to a computer, which is not intermediary communication equipment
 (e.g. a modem).

 Video terminals and printers are very similar devices from the point 
 of view of the operating system, both work with characters, and are
 characterized by: 

    Serial transmission speed    (Baud rate, typical 9600)
    Flow-control mechanism       (software: XON/XOFF, hardware: )
    Control character screening  (e.g. NUL (ASCII 0) ignored)
    Line width                   (typical 80,132 characters)
    Automatic line wrapping      (when enabled)

 Both device types get their input in the form of consecutive binary 
 numbers, usually 7-8 bits long each (sent big-endian at least in DEC), 
 and a deeper similarity is the way both devices generate characters 
 from these numbers.

 The device keeps a CHARACTER-SET (one or more), this is a kind of
 'graphic lookup table' that translates the binary numbers sent on the
 transmission line to graphic symbols that can be displayed or printed.

 If we can make the device to 'switch' the current character set, the 
 same input will generate different output.

 Older systems used 7-bits long binary numbers, and so could encode 
 only 128 different characters (0-127), newer systems use 8-bits codes, 
 and so can represent 256 characters (0-255).

 The first 128 codes have standard interpretation called ASCII (American 
 Standard Code for Information Interchange). IBM mainframes have their 
 own interpretation for these codes called EBCDIC. See ASCII and EBCDIC 
 tables in appendix B.

 The following topics may be relevant only to VTxxx terminals or

 National replacement sets
 When using the limited 7-bit character set, it's convenient to change
 the definition of some ASCII codes. 

 In the pound using countries (England), a pound sign is needed, and 
 may be implemented by redefining the '#' sign.

 In other countries, using larger alphabets, other signs like: 
 commercial at, square brackets, backslash, caret, underscore etc,
 may be 'appropriated' to implement the necessary letters.

 The higher codes
 The codes 128-255 have several possible interpretations or character
 sets, like:

    ISO Latin Alphabet Nr. 1
    ISO Latin Alphabet Nr. 2
    ISO Latin Alphabet Nr. 5
    ISO Latin - Cyrillic
    ISO Latin - Greek
    ISO Latin - Hebrew

 Compose sequences
 Standard keyboards can't generate all the lower (0-127) codes, and
 the full 8-bit character sets are hopeless.

 The standard way to extend the ability of keyboards, is adding 
 'modifier keys', like the 'shift' and 'control' keys. 

 Some keyboards has a 'compose character' key, special sequences of 
 key presses that start with 'compose' generate the higher characters.
 See your terminal documentation for instructions and more details.

 Control characters, escape and control sequences
 The codes 0-31 (C0 band) and 128-159 (C1 band) are reserved for 
 controlling the terminal, they perform functions like tabbing,
 carriage return, etc.

 Terminals can do a lot of useful things if sent the appropriate
 escape sequence - a sequence of regular characters prefixed by the
 'escape' (ASCII no. 27) code, for example:

    'escape' [ 1 3 ; 1 2 H         Put cursor in line 13, column 12
    'escape' [ 2 J                 Clear screen

 An extra 'space' character was added after each character to make
 the sequence more readable. 

 You can easily generate an escape sequence in FORTRAN:

      WRITE(*,*) CHAR(27), '[2J'

 This statement will clear the screen on any ANSI compatible video 
 terminal (e.g. VT100, xterm windows etc). 

 A small table of useful ANSI escape sequences:

    Property          Switch ON        Switch OFF     Whole page
    ===============   ==============   ============   ==============


 Soft character sets
 Some terminals have the ability to download a character-set from the
 host computer, the downloaded character-set has to be defined pixel
 by pixel and that information is sent to the terminal embedded in a 
 special escape sequence.

 This feature is useful if you need to display characters your terminal
 can't display.

 Optimizing terminal output for speed
 Scrolling is a very very slow operation, when updating the screen 
 place the cursor at the upper left corner before you start writing, 
 on an ANSI terminal you can use:

      WRITE (*,*) CHAR(27), '[1;1H'

 If you don't write full lines you may want to erase the screen before
 you place the cursor:

      WRITE (*,*) CHAR(27), '[2J', CHAR(27), '[1;1H'

 Moving the cursor, and in general using escape sequences is slower
 than using control characters like the  and  your program
 sends to the terminal to start new lines.

 Characters that are ignored by terminals
 An important example is the character NUL (ASCII 0). At least on VTnnn 
 compatible terminals (and probably others) this character is ignored. 

 That means that if the compiler initializes character strings to NUL 
 (e.g. DEC FORTRAN, Sun) writing an unassigned string to the string 
 produces no visible output (except starting a new line). 

 When writing a partly assigned string, only the assigned part
 will appear, a bit confusing to the uninitiated.

 Terminals and terminal drivers
 ...Blocking I/O...

Return to contents page