📄 termcap.texinfo
字号:
@file{/etc/termcap}. It contains terminal descriptions, blank lines, andcomments.A terminal description starts with one or more names for the terminal type.The information in the description is a series of @dfn{capability names}and values. The capability names have standard meanings(@pxref{Capabilities}) and their values describe the terminal.@menu* Format:: Overall format of a terminal description.* Capability Format:: Format of capabilities within a description.* Naming:: Naming conventions for terminal types.* Inheriting:: Inheriting part of a description from a related terminal type.@end menu@node Format, Capability Format, Data Base, Data Base@section Terminal Description Format@cindex description formatAside from comments (lines starting with @samp{#}, which are ignored), eachnonblank line in the termcap data base is a terminal description.A terminal description is nominally a single line, but it can be splitinto multiple lines by inserting the two characters @samp{\ newline}.This sequence is ignored wherever it appears in a description.The preferred way to split the description is between capabilities: insertthe four characters @samp{: \ newline tab} immediately before any colon.This allows each sub-line to start with some indentation. This worksbecause, after the @samp{\ newline} are ignored, the result is @samp{: tab:}; the first colon ends the preceding capability and the second colonstarts the next capability. If you split with @samp{\ newline} alone, youmay not add any indentation after them.Here is a real example of a terminal description:@exampledw|vt52|DEC vt52:\ :cr=^M:do=^J:nl=^J:bl=^G:\ :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:li#24:\ :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H:@end exampleEach terminal description begins with several names for the terminal type.The names are separated by @samp{|} characters, and a colon ends the lastname. The first name should be two characters long; it exists only for thesake of very old Unix systems and is never used in modern systems. Thelast name should be a fully verbose name such as ``DEC vt52'' or ``AnnArbor Ambassador with 48 lines''. The other names should include whateverthe user ought to be able to specify to get this terminal type, such as@samp{vt52} or @samp{aaa-48}. @xref{Naming}, for information on how tochoose terminal type names.After the terminal type names come the terminal capabilities, separated bycolons and with a colon after the last one. Each capability has atwo-letter name, such as @samp{cm} for ``cursor motion string'' or @samp{li}for ``number of display lines''.@node Capability Format, Naming, Format, Data Base@section Writing the CapabilitiesThere are three kinds of capabilities: flags, numbers, and strings. Eachkind has its own way of being written in the description. Each definedcapability has by convention a particular kind of value; for example,@samp{li} always has a numeric value and @samp{cm} always a string value.A flag capability is thought of as having a boolean value: the value istrue if the capability is present, false if not. When the capability ispresent, just write its name between two colons.A numeric capability has a value which is a nonnegative number. Write thecapability name, a @samp{#}, and the number, between two colons. Forexample, @samp{@dots{}:li#48:@dots{}} is how you specify the @samp{li}capability for 48 lines.@refillA string-valued capability has a value which is a sequence of characters.Usually these are the characters used to perform some display operation.Write the capability name, a @samp{=}, and the characters of the value,between two colons. For example, @samp{@dots{}:cm=\E[%i%d;%dH:@dots{}} ishow the cursor motion command for a standard ANSI terminal would bespecified.@refillSpecial characters in the string value can be expressed using@samp{\}-escape sequences as in C; in addition, @samp{\E} stands for@key{ESC}. @samp{^} is also a kind of escape character; @samp{^} followedby @var{char} stands for the control-equivalent of @var{char}. Thus,@samp{^a} stands for the character control-a, just like @samp{\001}.@samp{\} and @samp{^} themselves can be represented as @samp{\\} and@samp{\^}.@refillTo include a colon in the string, you must write @samp{\072}. You mightask, ``Why can't @samp{\:} be used to represent a colon?'' The reason isthat the interrogation functions do not count slashes while looking for acapability. Even if @samp{:ce=ab\:cd:} were interpreted as giving the@samp{ce} capability the value @samp{ab:cd}, it would also appear to define@samp{cd} as a flag.The string value will often contain digits at the front to specify padding(@pxref{Padding}) and/or @samp{%}-sequences within to specify how to encodeparameters (@pxref{Parameters}). Although these things are not to beoutput literally to the terminal, they are considered part of the value ofthe capability. They are special only when the string value is processedby @code{tputs}, @code{tparam} or @code{tgoto}. By contrast, @samp{\} and@samp{^} are considered part of the syntax for specifying the charactersin the string.Let's look at the VT52 example again:@exampledw|vt52|DEC vt52:\ :cr=^M:do=^J:nl=^J:bl=^G:\ :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:li#24:\ :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H:@end exampleHere we see the numeric-valued capabilities @samp{co} and @samp{li}, theflags @samp{bs} and @samp{pt}, and many string-valued capabilities. Mostof the strings start with @key{ESC} represented as @samp{\E}. The restcontain control characters represented using @samp{^}. The meanings of theindividual capabilities are defined elsewhere (@pxref{Capabilities}).@node Naming, Inheriting, Capability Format, Data Base@section Terminal Type Name Conventions@cindex names of terminal typesThere are conventions for choosing names of terminal types. For one thing,all letters should be in lower case. The terminal type for a terminal inits most usual or most fundamental mode of operation should not have ahyphen in it.If the same terminal has other modes of operation which requiredifferent terminal descriptions, these variant descriptions are givennames made by adding suffixes with hyphens. Such alternate descriptionsare used for two reasons:@itemize @bullet@itemWhen the terminal has a switch that changes its behavior. Since thecomputer cannot tell how the switch is set, the user must tell thecomputer by choosing the appropriate terminal type name.@cindex wrappingFor example, the VT-100 has a setup flag that controls whether thecursor wraps at the right margin. If this flag is set to ``wrap'',you must use the terminal type @samp{vt100-am}. Otherwise you mustuse @samp{vt100-nam}. Plain @samp{vt100} is defined as a synonym foreither @samp{vt100-am} or @samp{vt100-nam} depending on thepreferences of the local site.@refillThe standard suffix @samp{-am} stands for ``automatic margins''.@itemTo give the user a choice in how to use the terminal. This is donewhen the terminal has a switch that the computer normally controls.@cindex screen sizeFor example, the Ann Arbor Ambassador can be configured with manyscreen sizes ranging from 20 to 60 lines. Fewer lines make biggercharacters but more lines let you see more of what you are editing.As a result, users have different preferences. Therefore, termcapprovides terminal types for many screen sizes. If you choose type@samp{aaa-30}, the terminal will be configured to use 30 lines; if youchoose @samp{aaa-48}, 48 lines will be used, and so on.@end itemizeHere is a list of standard suffixes and their conventional meanings:@table @samp@item -wShort for ``wide''. This is a mode that gives the terminal morecolumns than usual. This is normally a user option.@item -am``Automatic margins''. This is an alternate description for use whenthe terminal's margin-wrap switch is on; it contains the @samp{am}flag. The implication is that normally the switch is off and theusual description for the terminal says that the switch is off.@item -nam``No automatic margins''. The opposite of @samp{-am}, this names analternative description which lacks the @samp{am} flag. This impliesthat the terminal is normally operated with the margin-wrap switchturned on, and the normal description of the terminal says so.@item -na``No arrows''. This terminal description initializes the terminal tokeep its arrow keys in local mode. This is a user option.@item -rv``Reverse video''. This terminal description causes text output fornormal video to appear as reverse, and text output for reverse videoto come out as normal. Often this description differs from the usualone by interchanging the two strings which turn reverse video on andoff.@refillThis is a user option; you can choose either the ``reverse video''variant terminal type or the normal terminal type, and termcap willobey.@item -s``Status''. Says to enable use of a status line which ordinary outputdoes not touch (@pxref{Status Line}).Some terminals have a special line that is used only as a status line.For these terminals, there is no need for an @samp{-s} variant; thestatus line commands should be defined by default. On otherterminals, enabling a status line means removing one screen line fromordinary use and reducing the effective screen height. For theseterminals, the user can choose the @samp{-s} variant type to requestuse of a status line.@item -@var{nlines}Says to operate with @var{nlines} lines on the screen, for terminalssuch as the Ambassador which provide this as an option. Normally thisis a user option; by choosing the terminal type, you control how manylines termcap will use.@item -@var{npages}pSays that the terminal has @var{npages} pages worth of screen memory,for terminals where this is a hardware option.@item -unkSays that description is not for direct use, but only for reference in@samp{tc} capabilities. Such a description is a kind of subroutine,because it describes the common characteristics of several variantdescriptions that would use other suffixes in place of @samp{-unk}.@end table@node Inheriting,, Naming, Data Base@section Inheriting from Related Descriptions@cindex inheritanceWhen two terminal descriptions are similar, their identical parts do notneed to be given twice. Instead, one of the two can be defined in terms ofthe other, using the @samp{tc} capability. We say that one description@dfn{refers to} the other, or @dfn{inherits from} the other.The @samp{tc} capability must be the last one in the terminal description,and its value is a string which is the name of another terminal type whichis referred to. For example,@exampleN9|aaa|ambassador|aaa-30|ann arbor ambassador/30 lines:\ :ti=\E[2J\E[30;0;0;30p:\ :te=\E[60;0;0;30p\E[30;1H\E[J:\ :li#30:tc=aaa-unk:@end example@noindentdefines the terminal type @samp{aaa-30} (also known as plain @samp{aaa}) interms of @samp{aaa-unk}, which defines everything about the Ambassador thatis independent of screen height. The types @samp{aaa-36}, @samp{aaa-48}and so on for other screen heights are likewise defined to inherit from@samp{aaa-unk}.The capabilities overridden by @samp{aaa-30} include @samp{li}, which sayshow many lines there are, and @samp{ti} and @samp{te}, which configure theterminal to use that many lines.The effective terminal description for type @samp{aaa} consists of the textshown above followed by the text of the description of @samp{aaa-unk}. The@samp{tc} capability is handled automatically by @code{tgetent}, whichfinds the description thus referenced and combines the two descriptions(@pxref{Find}). Therefore, only the implementor of the terminaldescriptions needs to think about using @samp{tc}. Users and applicationprogrammers do not need to be concerned with it.Since the reference terminal description is used last, capabilitiesspecified in the referring description override any specifications of thesame capabilities in the reference description.The referring description can cancel out a capability without specifyingany new value for it by means of a special trick. Write the capability inthe referring description, with the character @samp{@@} after the capabilityname, as follows:@exampleNZ|aaa-30-nam|ann arbor ambassador/30 lines/no automatic-margins:\ :am@@:tc=aaa-30:@end example@node Capabilities, Summary, Data Base, Top@chapter Definitions of the Terminal CapabilitiesThis section is divided into many subsections, each for one aspect ofuse of display terminals. For writing a display program, you usually needonly check the subsections for the operations you want to use. For writinga terminal description, you must read each subsection and fill in thecapabilities described there.String capabilities that are display commands may require numericparameters (@pxref{Parameters}). Most such capabilities do not useparameters. When a capability requires parameters, this is explicitlystated at the beginning of its definition. In simple cases, the first orsecond sentence of the definition mentions all the parameters, in the orderthey should be given, using a name@iftexin italics@end iftex@ifinfoin upper case@end ifinfofor each one. For example, the @samp{rp} capability is a command thatrequires two parameters; its definition begins as follows:@quotationString of commands to output a graphic character @var{c}, repeated @var{n}times.@end quotationIn complex cases or when there are many parameters, they are described
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -