📄 termcap.texinfo
字号:
explicitly.When a capability is described as obsolete, this means that programs shouldnot be written to look for it, but terminal descriptions should still bewritten to provide it.When a capability is described as very obsolete, this means that it shouldbe omitted from terminal descriptions as well.@menu* Basic:: Basic characteristics.* Screen Size:: Screen size, and what happens when it changes.* Cursor Motion:: Various ways to move the cursor.* Scrolling:: Pushing text up and down on the screen.* Wrapping:: What happens if you write a character in the last column.* Windows:: Limiting the part of the window that output affects.* Clearing:: Erasing one or many lines.* Insdel Line:: Making new blank lines in mid-screen; deleting lines.* Insdel Char:: Inserting and deleting characters within a line.* Standout:: Highlighting some of the text.* Underlining:: Underlining some of the text.* Cursor Visibility:: Making the cursor more or less easy to spot.* Bell:: Attracts user's attention; not localized on the screen.* Keypad:: Recognizing when function keys or arrows are typed.* Meta Key:: @key{META} acts like an extra shift key.* Initialization:: Commands used to initialize or reset the terminal.* Pad Specs:: Info for the kernel on how much padding is needed.* Status Line:: A status line displays ``background'' information.* Half-Line:: Moving by half-lines, for superscripts and subscripts.* Printer:: Controlling auxiliary printers of display terminals.@end menu@node Basic, Screen Size, Capabilities, Capabilities@section Basic CharacteristicsThis section documents the capabilities that describe the basic andnature of the terminal, and also those that are relevant to the outputof graphic characters.@table @samp@item os@kindex os@cindex overstrikeFlag whose presence means that the terminal can overstrike. Thismeans that outputting a graphic character does not erase whatever waspresent in the same character position before. The terminals that canoverstrike include printing terminals, storage tubes (all obsoletenowadays), and many bit-map displays.@item eo@kindex eoFlag whose presence means that outputting a space can erase anoverstrike. If this is not present and overstriking is supported,output of a space has no effect except to move the cursor.@item gn@kindex gn@cindex generic terminal typeFlag whose presence means that this terminal type is a generic typewhich does not really describe any particular terminal. Generic typesare intended for use as the default type assigned when the userconnects to the system, with the intention that the user shouldspecify what type he really has. One example of a generic typeis the type @samp{network}.Since the generic type cannot say how to do anything interesting withthe terminal, termcap-using programs will always find that theterminal is too weak to be supported if the user has failed to specifya real terminal type in place of the generic one. The @samp{gn} flagdirects these programs to use a different error message: ``You havenot specified your real terminal type'', rather than ``Your terminalis not powerful enough to be used''.@item hc@kindex hcFlag whose presence means this is a hardcopy terminal.@item rp@kindex rp@cindex repeat outputString of commands to output a graphic character @var{c}, repeated @var{n}times. The first parameter value is the ASCII code for the desiredcharacter, and the second parameter is the number of times to repeat thecharacter. Often this command requires padding proportional to the number of times the character is repeated. This effect can be had byusing parameter arithmetic with @samp{%}-sequences to compute theamount of padding, then generating the result as a number at the frontof the string so that @code{tputs} will treat it as padding.@item hz@kindex hzFlag whose presence means that the ASCII character @samp{~} cannot beoutput on this terminal because it is used for display commands.Programs handle this flag by checking all text to be output andreplacing each @samp{~} with some other character(s). If this is notdone, the screen will be thoroughly garbled.The old Hazeltine terminals that required such treatment are probablyvery rare today, so you might as well not bother to support this flag.@item CC@kindex CC@cindex command characterString whose presence means the terminal has a settable commandcharacter. The value of the string is the default command character(which is usually @key{ESC}).All the strings of commands in the terminal description should bewritten to use the default command character. If you are writing anapplication program that changes the command character, use the@samp{CC} capability to figure out how to translate all the displaycommands to work with the new command character.Most programs have no reason to look at the @samp{CC} capability.@item xb@kindex xb@cindex SuperbeeFlag whose presence identifies Superbee terminals which are unable totransmit the characters @key{ESC} and @kbd{Control-C}. Programs whichsupport this flag are supposed to check the input for the code sequencessent by the @key{F1} and @key{F2} keys, and pretend that @key{ESC}or @kbd{Control-C} (respectively) had been read. But this flag isobsolete, and not worth supporting.@end table@node Screen Size, Cursor Motion, Basic, Capabilities@section Screen Size@cindex screen sizeA terminal description has two capabilities, @samp{co} and @samp{li},that describe the screen size in columns and lines. But there is moreto the question of screen size than this.On some operating systems the ``screen'' is really a window and theeffective width can vary. On some of these systems, @code{tgetnum}uses the actual width of the window to decide what value to return forthe @samp{co} capability, overriding what is actually written in theterminal description. On other systems, it is up to the applicationprogram to check the actual window width using a system call. Forexample, on BSD 4.3 systems, the system call @code{ioctl} with code@code{TIOCGWINSZ} will tell you the current screen size.On all window systems, termcap is powerless to advise the applicationprogram if the user resizes the window. Application programs mustdeal with this possibility in a system-dependent fashion. On somesystems the C shell handles part of the problem by detecting changesin window size and setting the @code{TERMCAP} environment variableappropriately. This takes care of application programs that arestarted subsequently. It does not help application programs alreadyrunning.On some systems, including BSD 4.3, all programs using a terminal geta signal named @code{SIGWINCH} whenever the screen size changes.Programs that use termcap should handle this signal by using@code{ioctl TIOCGWINSZ} to learn the new screen size.@table @samp@item co@kindex co@cindex screen sizeNumeric value, the width of the screen in character positions. Evenhardcopy terminals normally have a @samp{co} capability.@item li@kindex liNumeric value, the height of the screen in lines.@end table@node Cursor Motion, Wrapping, Screen Size, Capabilities@section Cursor Motion@cindex cursor motionTermcap assumes that the terminal has a @dfn{cursor}, a spot on the screenwhere a visible mark is displayed, and that most display commands takeeffect at the position of the cursor. It follows that moving the cursorto a specified location is very important.There are many terminal capabilities for different cursor motionoperations. A terminal description should define as many as possible, butmost programs do not need to use most of them. One capability, @samp{cm},moves the cursor to an arbitrary place on the screen; this by itself issufficient for any application as long as there is no need to supporthardcopy terminals or certain old, weak displays that have only relativemotion commands. Use of other cursor motion capabilities is anoptimization, enabling the program to output fewer characters in somecommon cases.If you plan to use the relative cursor motion commands in an applicationprogram, you must know what the starting cursor position is. To do this,you must keep track of the cursor position and update the records eachtime anything is output to the terminal, including graphic characters.In addition, it is necessary to know whether the terminal wraps afterwriting in the rightmost column. @xref{Wrapping}.One other motion capability needs special mention: @samp{nw} moves thecursor to the beginning of the following line, perhaps clearing all thestarting line after the cursor, or perhaps not clearing at all. Thiscapability is a least common denominator that is probably supported even byterminals that cannot do most other things such as @samp{cm} or @samp{do}.Even hardcopy terminals can support @samp{nw}.@table @asis@item @samp{cm}@kindex cmString of commands to position the cursor at line @var{l}, column @var{c}.Both parameters are origin-zero, and are defined relative to thescreen, not relative to display memory.All display terminals except a few very obsolete ones support @samp{cm},so it is acceptable for an application program to refuse to operate onterminals lacking @samp{cm}.@item @samp{ho}@kindex ho@cindex home positionString of commands to move the cursor to the upper left corner of thescreen (this position is called the @dfn{home position}). Interminals where the upper left corner of the screen is not the same asthe beginning of display memory, this command must go to the upperleft corner of the screen, not the beginning of display memory.Every display terminal supports this capability, and many applicationprograms refuse to operate if the @samp{ho} capability is missing.@item @samp{ll}@kindex llString of commands to move the cursor to the lower left corner of thescreen. On some terminals, moving up from home position does this,but programs should never assume that will work. Just output the@samp{ll} string (if it is provided); if moving to home position andthen moving up is the best way to get there, the @samp{ll} commandwill do that.@item @samp{cr}@kindex crString of commands to move the cursor to the beginning of the line itis on. If this capability is not specified, many programs assumethey can use the ASCII carriage return character for this.@item @samp{le}@kindex leString of commands to move the cursor left one column. Unless the@samp{bw} flag capability is specified, the effect is undefined if thecursor is at the left margin; do not use this command there. If@samp{bw} is present, this command may be used at the left margin, andit wraps the cursor to the last column of the preceding line.@item @samp{nd}@kindex ndString of commands to move the cursor right one column. The effect isundefined if the cursor is at the right margin; do not use thiscommand there, not even if @samp{am} is present.@item @samp{up}@kindex upString of commands to move the cursor vertically up one line. Theeffect of sending this string when on the top line is undefined;programs should never use it that way.@item @samp{do}@kindex doString of commands to move the cursor vertically down one line. Theeffect of sending this string when on the bottom line is undefined;programs should never use it that way.The original idea was that this string would not contain a newlinecharacter and therefore could be used without disabling the kernel's usualhabit of converting of newline into a carriage-return newline sequence.But many terminal descriptions do use newline in the @samp{do} string, sothis is not possible; a program which sends the @samp{do} string mustdisable output conversion in the kernel (@pxref{Initialize}).@item @samp{bw}@kindex bwFlag whose presence says that @samp{le} may be used in column zeroto move to the last column of the preceding line. If this flagis not present, @samp{le} should not be used in column zero.@item @samp{nw}@kindex nwString of commands to move the cursor to start of next line, possiblyclearing rest of line (following the cursor) before moving.@item @samp{DO}, @samp{UP}, @samp{LE}, @samp{RI}@kindex DO@kindex LE@kindex RI@kindex UPStrings of commands to move the cursor @var{n} lines down vertically,up vertically, or @var{n} columns left or right. Do not attempt tomove past any edge of the screen with these commands; the effect oftrying that is undefined. Only a few terminal descriptions providethese commands, and most programs do not use them.@item @samp{CM}@kindex CMString of commands to position the cursor at line @var{l}, column@var{c}, relative to display memory. Both parameters are origin-zero.This capability is present only in terminals where there is adifference between screen-relative and memory-relative addressing, andnot even in all such terminals.@item @samp{ch}@kindex chString of commands to position the cursor at column @var{c} in thesame line it is on. This is a special case of @samp{cm} in which thevertical position is not changed. The @samp{ch} capability isprovided only when it is faster to output than @s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -