Thursday, September 18, 2008

Linux Terminal Emulation Graphics capabilities

The most important part of terminal emulation is how it displays information on the monitor. When you hear the phrase ‘‘text mode,’’ the last thing you’d think to worry about is graphics. However, even the most rudimentary dumb terminals supported some method of screen manipulation (such as clearing the screen and displaying text at a specific location on the screen).


Character sets
All terminals must display characters on the screen (otherwise, text mode would be pretty useless). The trick is in what characters to display, and what codes the Linux system needs to send to display them. A character set is a set of binary commands that the Linux system sends to a monitor to display characters. There are several character sets that are supported by various terminal emulation packages:

• ASCII The American Standard Code for Information Interchange. This character set contains the English characters stored using a 7-bit code, and consists of 128 English letters (both upper and lower case), numbers, and special symbols. This character set was adopted by the American National Standards Institute (ANSI) as US-ASCII. You will often see it referred to in terminal emulators as the ANSI character set.

• ISO-8859-1 (commonly called Latin-1) An extension of the ASCII character set developed by the International Organization for Standardization (ISO). It uses an 8-bit code to support the standard ASCII characters as well as special foreign language characters for most Western European languages. The Latin-1 character set is popular in multinational terminal emulation packages.

• ISO-8859-2 ISO character set that supports Eastern European language characters.

• ISO-8859-6 ISO character set that supports Arabic language characters.

• ISO-8859-7 ISO character set that supports Greek language characters.

• ISO-8859-8 ISO character set that supports Hebrew language characters.

• ISO-10646 (commonly called Unicode) ISO 2-byte character set that contains codes for most English and non-English languages. This single character set contains all of the codes defined in all of the ISO-8859-x series of character sets. The Unicode character set is quickly becoming popular among open source applications.

By far the most common character set in use today in English-speaking countries is the Latin-1 character set. The Unicode character set is becoming more popular, and may very well one day become the new standard in character sets. Most popular terminal emulators allow you to select which character set to use in the terminal emulation.


Control codes
Besides being able to display characters, terminals must have the ability to control special features on the monitor and keyboard, such as the cursor location on the screen. They accomplish this using a system of control codes. A control code is a special code not used in the character set, which signals the terminal to perform a special, nonprintable operation.

Common control code functions are the carriage return (return the cursor to the beginning of the line), line feed (put the cursor on the next horizontal row), horizontal tab (shift the cursor over a preset number of spaces), arrow keys (up, down, left, and right), and the page up/page down keys. While these codes mainly emulate features that control where the cursor is placed on the monitor, there are also several other codes, such as clearing the entire screen, and even a bell ring (emulating the old typewriter end-of-carriage bell).

Control codes were also used in controlling the communication features of dumb terminals. Dumb terminals were connected to the computer system via some type of communication channel, often a serial communication cable. Sometimes data needed to be controlled on the communication channel, so developers devised special control codes just for data communication purposes. While these codes aren’t necessarily required in modern terminal emulators, most support these codes to maintain compatibility. The most common codes in this category are the XON and XOFF codes, which start and stop data transmission to the terminal, respectively.


Block mode graphics
As dumb terminals became more popular, manufacturers started experimenting with rudimentary graphics capabilities. By far the most popular type of ‘‘graphical’’ dumb terminal used in the Unix world was the DEC VT series of terminals. The turning point for dumb terminals came with the release of the DEC VT100 in 1978. The DEC VT100 terminal was the first terminal to support the complete ANSI character set, including block mode graphic characters.

The ANSI character set contains codes that not only allowed monitors to display text but also rudimentary graphics symbols, such as boxes, lines, and blocks. By far one of the most popular dumb terminals used in Unix operations during the 1980s was the VT102, an upgraded version of the VT100. Most terminal emulation programs emulate the operation of the VT102 display, supporting all of the ANSI codes for creating block mode graphics.


Vector graphics
The Tektronix company produced a popular series of terminals that used a display method called vector graphics. Vector graphics deviated from the DEC method of block mode graphics by making all screen images (including characters) a series of line segments (vectors). The Tektronix 4010 terminal was the most popular graphical dumb terminal produced. Many terminal emulation packages still emulate its capabilities.

The 4010 terminal displays images by drawing a series of vectors using an electron beam, much like drawing with a pencil. Since vector graphics doesn’t use dots to create lines, it has the ability to draw geometric shapes using higher precision than most dot-oriented graphics terminals. This was a popular feature among mathematicians and scientists.

Terminal emulators use software to emulate the vector graphics drawing capabilities of the Tektronix 4010 terminals. This is still a popular feature for people who need precise graphical drawings, or those who still run applications that used the vector graphics routines to draw complicated charts and diagrams.


Display buffering
A key to graphics displays is the ability of the terminal to buffer data. Buffering data requires having additional internal memory within the terminal itself to store characters not currently being displayed on the monitor.

The DEC VT series of terminals utilized two types of data buffering:

• Buffering data as it scrolled off of the main display window (called a history)

• Buffering a completely separate display window (called an alternate screen)

The first type of buffering is known as a scroll region. The scroll region is the amount of memory the terminal has that enables it to ‘‘remember’’ data as it scrolls off of the screen. A standard DEC VT102 terminal contained a viewing area for 25 lines of characters. As the terminal displays a new line of characters, the previous line is scrolled upward. When the terminal reaches the bottom line of the display, the next line causes the top line to scroll off the display.

The internal memory in the VT102 terminal allowed it to save the last 64 lines that had scrolled off of the display. Users had the ability to lock the current screen display and use arrow keys to scroll backward through the previous lines that had ‘‘scrolled off’’ of the display. Terminal emulation packages allow you to use either a side scrollbar or a mouse scroll button to scroll through the saved data without having to lock the display. Of course, for full emulation compatibility, most terminal emulation packages also allow you to lock the display and use arrow and page up/page down to scroll through the saved data.

The second type of buffering is known as an alternative screen. Normally, the terminal writes data directly to the normal display area on the monitor. A method was developed to crudely implement animation by using two screen areas to store data. Control codes were used to signal the terminal to write data to the alternative screen instead of the current display screen. That data was held in memory. Another control code would signal the terminal to switch the monitor display between the normal screen data and the data contained in the alternative screen almost instantaneously. By storing successive data pages in the alternative screen area, then displaying it, you could crudely simulate moving graphics. Terminals that emulate the VT00 series of terminals have the ability to support the alternative screen method.


Color
Even back in the black-and-white (or green) dumb terminal days, programmers were experimenting with different ways to present data. Most terminals supported special control codes to produce the following types of special text:

• Bold characters
• Underline characters
• Reverse video (black characters on white background)
• Blinking
• Combinations of all of the above features

Back in the old days, if you wanted to get someone’s attention, you used bold, blinking, reverse video text. Now there’s something that could hurt your eyes! As color terminals became available, programmers added special control codes to display text in various colors and shades. The ANSI character set includes control codes for specifying specific colors for both foreground text and the background color displayed on the monitor. Most terminal emulators support the ANSI color control codes.

Source of Information : Wiley Linux Command Line and Shell Scripting Bible

No comments: