155 lines
8.2 KiB
HTML
155 lines
8.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
|
|
<TITLE> Text-Terminal-HOWTO: Some Details on How Terminals Work </TITLE>
|
|
<LINK HREF="Text-Terminal-HOWTO-9.html" REL=next>
|
|
<LINK HREF="Text-Terminal-HOWTO-7.html" REL=previous>
|
|
<LINK HREF="Text-Terminal-HOWTO.html#toc8" REL=contents>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="Text-Terminal-HOWTO-9.html">Next</A>
|
|
<A HREF="Text-Terminal-HOWTO-7.html">Previous</A>
|
|
<A HREF="Text-Terminal-HOWTO.html#toc8">Contents</A>
|
|
<HR>
|
|
<H2><A NAME="HowTermsWorkDetail"></A> <A NAME="s8">8.</A> <A HREF="Text-Terminal-HOWTO.html#toc8">Some Details on How Terminals Work </A></H2>
|
|
|
|
<P> If you know almost nothing about terminals, it's suggested that
|
|
you first read
|
|
<A HREF="Text-Terminal-HOWTO-1.html#intro">Introduction</A> and also read
|
|
<A HREF="Text-Terminal-HOWTO-6.html#overview">Overview of How Terminals Work</A>.</P>
|
|
|
|
<H2><A NAME="term_mem_detail"></A> <A NAME="ss8.1">8.1</A> <A HREF="Text-Terminal-HOWTO.html#toc8.1">Terminal Memory Details </A>
|
|
</H2>
|
|
|
|
<P> The
|
|
terminal screen refreshes itself at perhaps 60 times per second from
|
|
an image stored in the memory of the terminal. For a PC the monitor's
|
|
image is stored on the video card inside the computer but for a
|
|
terminal, the equivalent of the video card is inside the terminal.
|
|
For a text terminal the storage of the image uses little memory.
|
|
Instead of putting every dot (pixel) on the screen into memory and
|
|
requiring the storage of about a quarter-million dots, a much more
|
|
efficient method of storage is used.</P>
|
|
<P>A screen-full of text may be represented inside the terminal memory by
|
|
ASCII bytes, one for each character on the screen. An entire screen
|
|
only takes about 2K ASCII bytes. To display these characters, the
|
|
terminal must also know the bit-map (the shape) of each of the almost
|
|
100 printable ASCII characters. With a bit-map of a character using
|
|
say 15 bytes, only about 1.5K of memory is needed for the bit-maps of
|
|
all the ASCII characters (the font). This ASCII text and font memory
|
|
is scanned so that the resulting image is put on the screen about 60
|
|
times each second. This is a form of shared memory where a single
|
|
bit-map of a letter such as the letter e, is shared by all of the many
|
|
letter e's which appear on a screen-full of text. Low memory
|
|
requirements meant low costs to produce monitors in the early 1980's
|
|
when the cost of memory was several thousand times higher than it is
|
|
today (costing then several dollars per kilobyte).</P>
|
|
|
|
<H2><A NAME="early_terms"></A> <A NAME="ss8.2">8.2</A> <A HREF="Text-Terminal-HOWTO.html#toc8.2">Early Terminals </A>
|
|
</H2>
|
|
|
|
<P> The first terminals were something like remotely controlled
|
|
typewriters which could only "display" (print on paper) the character
|
|
stream sent to them from the computer. The earliest models were
|
|
called
|
|
<A HREF="Text-Terminal-HOWTO-24.html#teletype">Teletypes</A>. The name "tty" is just
|
|
an abbreviation for "Teletype". Early terminals could do a line feed
|
|
and a carriage return just like a typewriter and ring a bell when a
|
|
bell character was received. Due to the lack of significant
|
|
capabilities this was the first type of terminal to be labeled "dumb".
|
|
This type of terminal interface (using a terminal type called "dumb")
|
|
is sometimes used today when the computer can't figure out what kind
|
|
of a terminal it is communicating with.</P>
|
|
|
|
<H2><A NAME="ss8.3">8.3</A> <A HREF="Text-Terminal-HOWTO.html#toc8.3">Escape Sequences and Control Codes (intro) </A>
|
|
</H2>
|
|
|
|
<P> Terminals have
|
|
many capabilities some of which are always present and some of which
|
|
require commands from the computer to change or activate. To exercise
|
|
all these capabilities under the control of the computer requires that
|
|
special codes be established so that the computer can tell the
|
|
terminal what to do. There are two major type of such codes: escape
|
|
sequences and control codes (control characters). There are many
|
|
times more escape sequences than control codes.</P>
|
|
|
|
<H3><A NAME="control_codes"></A> Control codes </H3>
|
|
|
|
<P> The control
|
|
codes (or control characters) consist of the first 32 bytes of the
|
|
ASCII alphabet. They include the following: carriage-return (cursor
|
|
to far left), line-feed (cursor down one line), backspace,
|
|
escape-character, tab, and bell. They do not normally show on the
|
|
screen. There is usually a command which you may give to your
|
|
terminal which will result in them being displayed when they are
|
|
received by the terminal. It's called something like "Display
|
|
Controls" or "Monitor". If you do this then the display may look a
|
|
mess since escape sequences, which all start with the ESC (escape)
|
|
control character, are no longer executed. Words which should appear
|
|
at the top or bottom of the screen will show up in other locations.
|
|
The escape sequences to reposition the cursor display on the screen
|
|
but the cursor doesn't move to where the escape sequence says.</P>
|
|
|
|
<H3><A NAME="esc_seq"></A> Escape sequences </H3>
|
|
|
|
<P> Since there are not
|
|
nearly enough control codes to do everything (and for some reason, not
|
|
all of them are utilized) many escape sequences are used. They
|
|
consist of the "escape" (ESC) control character followed by a sequence
|
|
of ordinary characters. Upon receiving an escape character, the
|
|
terminal examines the characters following it so that it may interpret
|
|
the sequence and carry out the intended command from the computer.
|
|
Once it recognizes the end of a valid sequence, further characters
|
|
received just display on the screen (unless they are control codes or
|
|
more escape sequences). Some escape sequences may take parameters (or
|
|
arguments) such as the coordinates on the screen to move the cursor
|
|
to. The parameters become a part of the escape sequence. An
|
|
<A HREF="Text-Terminal-HOWTO-22.html#esc_seq_lists">Esc Sequence List</A> is on the web for some
|
|
terminals, but it's terse.</P>
|
|
<P>A list of the escape sequences for your terminal should be in the
|
|
"programmers manual" for the terminal. Except for very old terminals,
|
|
there may be two or three hundred such sequences. If you don't have a
|
|
such manual it's not easy to find them. Some of the sequences are
|
|
available on the Internet. One link is
|
|
<A HREF="Text-Terminal-HOWTO-22.html#esc_seq_lists">Esc Sequence List</A>. By searching the Internet for one sequence
|
|
(such as ESC[5m) you may come across a long list of them.</P>
|
|
<P>Another way to determine some of them is to find the terminfo entry
|
|
(termcap) for the terminal and mentally decode it. See
|
|
<A HREF="Text-Terminal-HOWTO-16.html#termcap2">Terminfo and Termcap (detailed)</A> in this document
|
|
and/or the
|
|
<A HREF="Text-Terminal-HOWTO-16.html#termcap_docs">Termcap Manual</A> on the
|
|
Internet. Unfortunately, the terminfo (termcap) for a terminal often
|
|
does not list all of the escape sequences which the terminal has
|
|
available for use, but fortunately, the most important ones are
|
|
usually there.</P>
|
|
|
|
<H2><A NAME="display_attributes"></A> <A NAME="ss8.4">8.4</A> <A HREF="Text-Terminal-HOWTO.html#toc8.4">Display Attributes & Magic Cookies </A>
|
|
</H2>
|
|
|
|
<P> Terminals have various methods of
|
|
generating character attributes such as bold, reverse-video,
|
|
underlining, etc. There should be no need for the user to worry about
|
|
how this is done, except that it creates problems for some old
|
|
terminals and there is sometimes an option for this in the set-up menu
|
|
of newer terminals.</P>
|
|
<P>The magic cookie method is obsolete. It's the simplest (and worst)
|
|
method of defining attributes: Use a certain byte for the start of an
|
|
attribute and another to end that attribute. For example, a "start
|
|
underlining" magic cookie byte is placed just before the first word to
|
|
be underlined. These extra bytes are put into the memory of the
|
|
screen page, just like character bytes that display as characters.
|
|
But this might foul up the count of the number of characters per line
|
|
since non-printable magic cookie characters are intermingled with
|
|
other printable characters. This sometimes causes problems.</P>
|
|
<P>A better method which uses more memory is to assign an attribute byte
|
|
(or half=byte, etc.) to each displayed character. This method is used
|
|
by PC video cards (for text) for the common PC monitor.</P>
|
|
|
|
<HR>
|
|
<A HREF="Text-Terminal-HOWTO-9.html">Next</A>
|
|
<A HREF="Text-Terminal-HOWTO-7.html">Previous</A>
|
|
<A HREF="Text-Terminal-HOWTO.html#toc8">Contents</A>
|
|
</BODY>
|
|
</HTML>
|