Tput
Encyclopedia
In computing
Computing
Computing is usually defined as the activity of using and improving computer hardware and software. It is the computer-specific part of information technology...

, tput is a standard Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

 command which is used to set terminal
Computer terminal
A computer terminal is an electronic or electromechanical hardware device that is used for entering data into, and displaying data from, a computer or a computing system...

 features.

Depending on the system, tput uses the terminfo
Terminfo
Terminfo is a library and database that enables programs to use display terminals in a device-independent manner. This library has its origins in the UNIX System III operating system....

 or termcap
Termcap
Termcap is a software library and database used on Unix-like computers. It enables programs to use display computer terminals in a device-independent manner, which greatly simplifies the process of writing portable text mode applications...

 database, as well as looking into the environment
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...

 for the terminal type.

History

Tput was provided in UNIX System V
UNIX System V
Unix System V, commonly abbreviated SysV , is one of the first commercial versions of the Unix operating system. It was originally developed by American Telephone & Telegraph and first released in 1983. Four major versions of System V were released, termed Releases 1, 2, 3 and 4...

 in the early 1980s. A clone of the AT&T
AT&T
AT&T Inc. is an American multinational telecommunications corporation headquartered in Whitacre Tower, Dallas, Texas, United States. It is the largest provider of mobile telephony and fixed telephony in the United States, and is also a provider of broadband and subscription television services...

 tput was submitted to volume 7 of the mod.sources newsgroup (later comp.sources.unix) in September 1986. In contrast to the System V program, the clone used termcap rather than terminfo. It accepted command-line parameters for the cm (cursor addressing) capability, and recognized terminfo capability names.

System V Release 3 provided an improved version which combined the different initialization capabilities as a new option init, and the reset capabilities as reset, thereby simplifying use of tput for initializing or reinitializing the terminal. System V Release 3.2 added several printer-specific capabilities to the terminfo database, such as swidm (enter_doublewide_mode) which tput could use. It also added capabilities for color.

System V Release 4 defined additional terminfo capabilities including standardized ANSI color capabilities setaf and setab, which could be used by tput.

BSD platforms provided a different implementation of tput in 4.3BSD-Reno (June 1990). It used termcap, recognizing only termcap capability names, and did not accept command-line parameters for cursor-addressing. FreeBSD
FreeBSD
FreeBSD is a free Unix-like operating system descended from AT&T UNIX via BSD UNIX. Although for legal reasons FreeBSD cannot be called “UNIX”, as the direct descendant of BSD UNIX , FreeBSD’s internals and system APIs are UNIX-compliant...

 used this in 1994, improving it by accepting one or two numeric command-line parameters.

Ross Ridge's mytinfo package in 1992 provided a tput which accepted either termcap or terminfo capability names. Like the Reno implementation, it did not pass command-line arguments to parameterized capabilities. ncurses
Ncurses
ncurses is a programming library that provides an API which allows the programmer to write text user interfaces in a terminal-independent manner. It is a toolkit for developing "GUI-like" application software that runs under a terminal emulator...

 incorporated the mytinfo code in June 1995. The initial version added a -S option, and interpreted command-line parameters as described in the System V Release 4 documentation.

Portability

The Open Group defines one option (-T, to specify the terminal type) and three keywords (init, clear and reset).
Most implementations accept the name of a terminal capability together with any parameters that may be needed for that.
However, some implementations expect a termcap
Termcap
Termcap is a software library and database used on Unix-like computers. It enables programs to use display computer terminals in a device-independent manner, which greatly simplifies the process of writing portable text mode applications...

 name, while others expect a terminfo
Terminfo
Terminfo is a library and database that enables programs to use display terminals in a device-independent manner. This library has its origins in the UNIX System III operating system....

 name.

All System V Release 4 implementations, as well as those which are designed to be compatible, also recognize a -S option (to tell tput to read data from the standard input), and an additional keyword longname. They also accept command-line parameters, usually distinguishing numeric from string parameters by the form of the parameter, checking for all-numeric characters. That makes it impossible for example to set a function-key label to a string of digits. Using a different approach, ncurses determines the expected type of the parameters with a table of the terminfo capabilities which use string parameters, eliminating the ambiguity.

Usage

Action Parameters
Background color tput setab [1-7]
foreground color tput setaf [1-7]
bold mode tput bold
half-bright mode tput dim
underline mode tput smul
exit underline mode tput rmul
reverse mode tput rev
standout mode tput smso
Exit standout mode tput rmso
reset all attributes tput sgr0

1: red, 2: Green, 3= Yellow, 4= Blue, 5= Purple, 6= Cyan, 7= White


To make terminal font color red
tput setaf 1

External links


Manual pages


Tutorials

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK