Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Data model  



1.1  Indices  





1.2  Data values  





1.3  Hierarchy  







2 Storage model  



2.1  Environment variables  





2.2  Flat file  





2.3  Hashed database  







3 Limitations and extensions  





4 Obsolete features  





5 See also  





6 References  





7 External links  














Termcap






Español
Français

Русский
 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


Termcap (terminal capability) is a legacy software library and database used on Unix-like computers that enables programs to use display computer terminals in a device-independent manner, which greatly simplifies the process of writing portable text mode applications. It was superseded by the terminfo database used by ncurses, tput, and other programs.

Bill Joy wrote the first termcap library in 1978[1][2] for the Berkeley Unix operating system; it has since been ported to most Unix and Unix-like environments, even OS-9.[3] Joy's design was reportedly influenced by the design of the terminal data store in the earlier Incompatible Timesharing System.[4][better source needed][dubiousdiscuss]

A termcap database can describe the capabilities of hundreds of different display terminals. This allows programs to have character-based display output, independent of the type of terminal. On-screen text editors such as vi and Emacs are examples of programs that may use termcap. Other programs are listed in the Termcap category.

Examples of what the database describes:

Data model[edit]

Termcap databases consist of one or more descriptions of terminals.

Indices[edit]

Each description must contain the canonical name of the terminal. It may also contain one or more aliases for the name of the terminal. The canonical name or aliases are the keys by which the library searches the termcap database.

Data values[edit]

The description contains one or more capabilities, which have conventional names. The capabilities are typed: boolean, numeric and string. The termcap library has no predetermined type for each capability name. It determines the types of each capability by the syntax:

Applications which use termcap do expect specific types for the commonly used capabilities, and obtain the values of capabilities from the termcap database using library calls that return successfully only when the database contents matches the assumed type.

Hierarchy[edit]

Termcap descriptions can be constructed by including the contents of one description in another, suppressing capabilities from the included description or overriding or adding capabilities. No matter what storage model is used, the termcap library constructs the terminal description from the requested description, including, suppressing or overriding at the time of the request.

Storage model[edit]

Termcap data is stored as text, making it simple to modify. The text can be retrieved by the termcap library from files or environment variables.

Environment variables[edit]

The TERM environment variable contains the terminal type name.

The TERMCAP environment variable may contain a termcap database. It is most often used to store a single termcap description, set by a terminal emulator to provide the terminal's characteristics to the shell and dependent programs.

The TERMPATH environment variable is supported by newer termcap implementations and defines a search path for termcap files.

Flat file[edit]

The original (and most common) implementation of the termcap library retrieves data from a flat text file. Searching a large termcap file, e.g., 500 kB, can be slow. To aid performance, a utility such as reorder is used to put the most frequently used entries near the beginning of the file.

Hashed database[edit]

4.4BSD based implementations of termcap store the terminal description in a hashed database (e.g., something like Berkeley DB version 1.85). These store two types of records: aliases which point to the canonical entry, and the canonical entry itself. The text of the termcap entry is stored literally.

Limitations and extensions[edit]

The original termcap implementation was designed to use little memory:

Newer implementations of the termcap interface generally do not require the two-character name at the beginning of the entry.

Capability names are still two characters in all implementations.

The tgetent function used to read the terminal description uses a buffer whose size must be large enough for the data, and is assumed to be 1024 characters. Newer implementations of the termcap interface may relax this constraint by allowing a null pointer in place of the fixed buffer,[5] or by hiding the data which would not fit, e.g., via the ZZ capability in NetBSD termcap.[6] The terminfo library interface also emulates the termcap interface, and does not actually use the fixed-size buffer.

The terminfo library's emulation of termcap allows multiple other entries to be included without restricting the position. A few other newer implementations of the termcap library may also provide this ability, though it is not well documented.[7]

Obsolete features[edit]

A special capability, the "hz" capability, was defined specifically to support the Hazeltine 1500 terminal, which had the unfortunate characteristic of using the ASCII tilde character ('~') as a control sequence introducer.[8][discuss] In order to support that terminal, not only did code that used the database have to know about using the tilde to introduce certain control sequences, but it also had to know to substitute another printable character for any tildes in the displayed text, since a tilde in the text would be interpreted by the terminal as the start of a control sequence, resulting in missing text and screen garbling.[9] Additionally, attribute markers (such as start and end of underlining) themselves took up space on the screen.[citation needed] Comments in the database source code often referred to this as "Hazeltine braindamage".[10] Since the Hazeltine 1500 was a widely used terminal in the late 1970s,[citation needed] it was important for applications to be able to deal with its limitations.

See also[edit]

References[edit]

  • ^ Joel Mathew Hegberg (November 1994). "Tackling Termcap, Part I". OS-9/OSK Answers!. Retrieved 26 April 2021.
  • ^ Mark Crispin (7 Oct 1998). "Re: KL Console Commands". Newsgroupalt.sys.pdp10.
  • ^ The GNU Termcap Library
  • ^ NetBSD termcap file format
  • ^ Discussion of termcap in vi
  • ^ termcap(5) – BSD File Formats Manual
  • ^ Stallman, Richard M. (1992). "The Termcap Library and Database, Second Edition". Gnu.org. Retrieved 17 May 2014.
  • ^ "termcap.src". Apple Computer. Retrieved 17 May 2014.
  • External links[edit]


    Retrieved from "https://en.wikipedia.org/w/index.php?title=Termcap&oldid=1190798855"

    Categories: 
    Termcap
    Computer data
    Databases
    Text mode
    1978 software
    Hidden categories: 
    All articles lacking reliable references
    Articles lacking reliable references from April 2021
    All accuracy disputes
    Articles with disputed statements from April 2021
    All articles with unsourced statements
    Articles with unsourced statements from May 2014
     



    This page was last edited on 19 December 2023, at 22:49 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki