ArticleslgStudy

computer science

Terminal capabilities

Terminal capabilities is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Terminal capabilities rather than just read about it. In short: In computing and telecommunications, the capabilities of a terminal are various terminal features, above and beyond what is available from a pure teletypewriter, that host systems (and the programs that run on them) can make use of. They are (mainly) control codes and escape codes that can be sent to or received from the terminal.

Key takeaways

  • Terminal capabilities belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Terminal capabilities to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Terminal capabilities from memory before moving on to harder problems.

Reference excerpt

In computing and telecommunications, the capabilities of a terminal are various terminal features, above and beyond what is available from a pure teletypewriter, that host systems (and the programs that run on them) can make use of. They are (mainly) control codes and escape codes that can be sent to or received from the terminal. The escape codes sent to the terminal perform various functions that a CRT terminal (and software terminal emulators) is capable of, but that a teletypewriter is not; such as moving the terminal's cursor to positions on the screen, clearing and scrolling all or parts of the screen, turning on and off attached printer devices, programming programmable function keys, changing display colours and attributes (such as reverse video), and setting display title strings. The escape codes received from the terminal signify things such as function key, arrow key, and other special key (home key, end key, help key, PgUp key, PgDn key, insert key, delete key, and so forth) keystrokes.

Unix and POSIX: termcap, terminfo, et al. In Unix and other POSIX-compliant systems that support the POSIX terminal interface, these capabilities are encoded in databases that are configured by a system administrator and accessed from programs via the terminfo library (which supersedes the older termcap library), upon which in turn are built libraries such as the curses and ncurses libraries, by which applications programs use the terminal capabilities to provide textual user interfaces with windows, dialogue boxes, buttons, labels, input fields, menus, and so forth. The intention is that this allows applications programs to be independent of actual terminal characteristics. They don't need to hardwire any control codes or escape sequences into their code, and so don't have problems being used on a range of terminals with a range of capabilities.

termcap

The termcap (for "terminal capabilities") library was developed for BSD systems. It uses a database stored in the file /etc/termcap. This database consists of a series of records (each of which consists of one or more lines in the file, joined by backslash characters at the ends of each line that continues onto a following one) each of which represents the capabilities of a particular terminal. The fields of the record comprise the terminal type name, or names, followed by a sequence of capabilities, separated by colons. The capability fields themselves fall into three groups:

characteristics of the terminal These comprise such things as the (nominal) number of rows and columns the terminal's display has, whether output automatically wraps onto the next line when it reaches the end of a line, and so forth. control sequences sent as output to the terminal These comprise the control codes and escape sequences sent to the terminal in order for it to perform some action (not necessarily a display action). An example of one of the simplest is the output sequence to clear the screen, which may be the form feed (ASCII FF) character on some types of terminal but may, say, be the escape sequence ␛2J on a terminal that requires ANSI escape sequences. control sequences sent as input by the terminal These comprise the control codes and escape sequences that the terminal sends to the host to represent various actions and events, such as function keys and arrow keys being pressed.

terminfo

The terminfo ("terminal information") library was developed for System V systems. It uses a database stored in multiple files within a directory, which can be variously (on different Unices and POSIX-compatible systems) /usr/lib/terminfo, /usr/share/terminfo, or even /usr/share/lib/terminfo. (Its location isn't even uniform across different distributions of Linux.)

Unlike the termcap database, the terminfo database is compiled, a machine-readable database that is constructed from a human-readable source file format by a utility program, tic. They can be decompiled from machine-readable form back to human-readable form by another utility program, infocmp. The command to output the human-readable form of the "vt100" terminal definition, for example, is: The use of a machine-readable format was to avoid the unnecessary overhead, in applications programs using systems such as the termcap library, of repeatedly parsing the database content to read the fields of a record. The use of multiple files was to avoid the similar overhead of parsing the database content to find the database record for the target terminal type. The terminal type name index is, effectively, the Unix/POSIX filesystem's ordinary directory structure. Originally, Unix had severe performance problems with large directories containing many files, and thus terminfo uses a two-level structure, dividing up the directory entries by first letter into a series of subdirectories. More recent filesystem formats used on Unix systems don't suffer as much from such problems (because their on-disc directory structures are no longer simple arrays of entries, but are organized into trees or hash tables) and so the necessity for this design element, that still exists in modern terminfo implementations, has since disappeared.

Utility programs to exercise terminal capabilities

On Unix systems, the tput command is used to look up a specific capability in the system's database, and output it to the command's standard output (which is, presumably, the terminal by which the function denoted by the capability is to be performed). One of the simplest operations is clearing the screen. The name of the database field that stores the output sequence for this is clear, so the command arguments to the tput program to clear the screen are Another operation is initializing or resetting the terminal to a known default state (of character attributes, fonts, colours, and so forth). The commands for this are: and Normally the tput command uses the terminal type specified by the TERM environment variable, one of the controlling environment variables of the POSIX terminal interface. This can be overridden, however, to force tput to look up a different terminal type in the database, with a command-line option to the command. So, for example, to issue the reset sequence appropriate for the type of terminal named "vt100" in the database (usually a DEC VT100 terminal), irrespective of terminal type specified in environment variables, the command is:

References

What supports what

Sources used

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Terminal capabilities

Start with the simplest possible case. Write down what Terminal capabilities claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Terminal capabilities before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Terminal capabilities ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Terminal capabilities

In research
Terminal capabilities appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Terminal capabilities in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Terminal capabilities is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer terminals, Telecommunications equipment, so understanding it makes those chapters shorter.
In everyday life
Look for Terminal capabilities outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Terminal capabilities” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Terminal capabilities in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Terminal capabilities means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Terminal capabilities out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Terminal capabilities in simple terms?

In computing and telecommunications, the capabilities of a terminal are various terminal features, above and beyond what is available from a pure teletypewriter, that host systems (and the programs that run on them) can make use of. They are (mainly) control codes and escape codes that can be sent…

Why does Terminal capabilities matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Terminal capabilities?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Terminal capabilities.

Tags

  • Computer terminals
  • Telecommunications equipment

Keep exploring