home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / termcap.i02 < prev    next >
Encoding:
GNU Info File  |  1993-06-14  |  44.1 KB  |  999 lines

  1. This is Info file ../info/termcap, produced by Makeinfo-1.47 from the
  2. input file termcap.texi.
  3.  
  4.    This file documents the termcap library of the GNU system.
  5.  
  6.    Copyright (C) 1988 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that
  14. the entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.  
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that this permission notice may be stated in a
  20. translation approved by the Foundation.
  21.  
  22. 
  23. File: termcap,  Node: Capabilities,  Next: Summary,  Prev: Data Base,  Up: Top
  24.  
  25. Definitions of the Terminal Capabilities
  26. ****************************************
  27.  
  28.    This section is divided into many subsections, each for one aspect of
  29. use of display terminals.  For writing a display program, you usually
  30. need only check the subsections for the operations you want to use. 
  31. For writing a terminal description, you must read each subsection and
  32. fill in the capabilities described there.
  33.  
  34.    String capabilities that are display commands may require numeric
  35. parameters (*note Parameters::.).  Most such capabilities do not use
  36. parameters.  When a capability requires parameters, this is explicitly
  37. stated at the beginning of its definition.  In simple cases, the first
  38. or second sentence of the definition mentions all the parameters, in
  39. the order they should be given, using a name in upper case for each
  40. one.  For example, the `rp' capability is a command that requires two
  41. parameters; its definition begins as follows:
  42.  
  43.      String of commands to output a graphic character C, repeated N
  44.      times.
  45.  
  46.    In complex cases or when there are many parameters, they are
  47. described explicitly.
  48.  
  49.    When a capability is described as obsolete, this means that programs
  50. should not be written to look for it, but terminal descriptions should
  51. still be written to provide it.
  52.  
  53.    When a capability is described as very obsolete, this means that it
  54. should be omitted from terminal descriptions as well.
  55.  
  56. * Menu:
  57.  
  58. * Basic::             Basic characteristics.
  59. * Screen Size::       Screen size, and what happens when it changes.
  60. * Cursor Motion::     Various ways to move the cursor.
  61. * Scrolling::         Pushing text up and down on the screen.
  62. * Wrapping::          What happens if you write a character in the last column.
  63. * Windows::           Limiting the part of the window that output affects.
  64. * Clearing::          Erasing one or many lines.
  65. * Insdel Line::       Making new blank lines in mid-screen; deleting lines.
  66. * Insdel Char::       Inserting and deleting characters within a line.
  67. * Standout::          Highlighting some of the text.
  68. * Underlining::       Underlining some of the text.
  69. * Cursor Visibility:: Making the cursor more or less easy to spot.
  70. * Bell::              Attracts user's attention; not localized on the screen.
  71. * Keypad::            Recognizing when function keys or arrows are typed.
  72. * Meta Key::          META acts like an extra shift key.
  73. * Initialization::    Commands used to initialize or reset the terminal.
  74. * Pad Specs::         Info for the kernel on how much padding is needed.
  75. * Status Line::       A status line displays "background" information.
  76. * Half-Line::         Moving by half-lines, for superscripts and subscripts.
  77. * Printer::           Controlling auxiliary printers of display terminals.
  78.  
  79. 
  80. File: termcap,  Node: Basic,  Next: Screen Size,  Prev: Capabilities,  Up: Capabilities
  81.  
  82. Basic Characteristics
  83. =====================
  84.  
  85.    This section documents the capabilities that describe the basic and
  86. nature of the terminal, and also those that are relevant to the output
  87. of graphic characters.
  88.  
  89. `os'
  90.      Flag whose presence means that the terminal can overstrike.  This
  91.      means that outputting a graphic character does not erase whatever
  92.      was present in the same character position before.  The terminals
  93.      that can overstrike include printing terminals, storage tubes (all
  94.      obsolete nowadays), and many bit-map displays.
  95.  
  96. `eo'
  97.      Flag whose presence means that outputting a space can erase an
  98.      overstrike.  If this is not present and overstriking is supported,
  99.      output of a space has no effect except to move the cursor.
  100.  
  101. `gn'
  102.      Flag whose presence means that this terminal type is a generic type
  103.      which does not really describe any particular terminal.  Generic
  104.      types are intended for use as the default type assigned when the
  105.      user connects to the system, with the intention that the user
  106.      should specify what type he really has.  One example of a generic
  107.      type is the type `network'.
  108.  
  109.      Since the generic type cannot say how to do anything interesting
  110.      with the terminal, termcap-using programs will always find that the
  111.      terminal is too weak to be supported if the user has failed to
  112.      specify a real terminal type in place of the generic one.  The
  113.      `gn' flag directs these programs to use a different error message:
  114.      "You have not specified your real terminal type", rather than
  115.      "Your terminal is not powerful enough to be used".
  116.  
  117. `hc'
  118.      Flag whose presence means this is a hardcopy terminal.
  119.  
  120. `rp'
  121.      String of commands to output a graphic character C, repeated N
  122.      times.  The first parameter value is the ASCII code for the desired
  123.      character, and the second parameter is the number of times to
  124.      repeat the character.  Often this command requires padding
  125.      proportional to the number of times the character is repeated. 
  126.      This effect can be had by using parameter arithmetic with
  127.      `%'-sequences to compute the amount of padding, then generating
  128.      the result as a number at the front of the string so that `tputs'
  129.      will treat it as padding.
  130.  
  131. `hz'
  132.      Flag whose presence means that the ASCII character `~' cannot be
  133.      output on this terminal because it is used for display commands.
  134.  
  135.      Programs handle this flag by checking all text to be output and
  136.      replacing each `~' with some other character(s).  If this is not
  137.      done, the screen will be thoroughly garbled.
  138.  
  139.      The old Hazeltine terminals that required such treatment are
  140.      probably very rare today, so you might as well not bother to
  141.      support this flag.
  142.  
  143. `CC'
  144.      String whose presence means the terminal has a settable command
  145.      character.  The value of the string is the default command
  146.      character (which is usually ESC).
  147.  
  148.      All the strings of commands in the terminal description should be
  149.      written to use the default command character.  If you are writing
  150.      an application program that changes the command character, use the
  151.      `CC' capability to figure out how to translate all the display
  152.      commands to work with the new command character.
  153.  
  154.      Most programs have no reason to look at the `CC' capability.
  155.  
  156. `xb'
  157.      Flag whose presence identifies Superbee terminals which are unable
  158.      to transmit the characters ESC and `Control-C'.  Programs which
  159.      support this flag are supposed to check the input for the code
  160.      sequences sent by the F1 and F2 keys, and pretend that ESC or
  161.      `Control-C' (respectively) had been read.  But this flag is
  162.      obsolete, and not worth supporting.
  163.  
  164. 
  165. File: termcap,  Node: Screen Size,  Next: Cursor Motion,  Prev: Basic,  Up: Capabilities
  166.  
  167. Screen Size
  168. ===========
  169.  
  170.    A terminal description has two capabilities, `co' and `li', that
  171. describe the screen size in columns and lines.  But there is more to
  172. the question of screen size than this.
  173.  
  174.    On some operating systems the "screen" is really a window and the
  175. effective width can vary.  On some of these systems, `tgetnum' uses the
  176. actual width of the window to decide what value to return for the `co'
  177. capability, overriding what is actually written in the terminal
  178. description.  On other systems, it is up to the application program to
  179. check the actual window width using a system call.  For example, on BSD
  180. 4.3 systems, the system call `ioctl' with code `TIOCGWINSZ' will tell
  181. you the current screen size.
  182.  
  183.    On all window systems, termcap is powerless to advise the application
  184. program if the user resizes the window.  Application programs must deal
  185. with this possibility in a system-dependent fashion.  On some systems
  186. the C shell handles part of the problem by detecting changes in window
  187. size and setting the `TERMCAP' environment variable appropriately. 
  188. This takes care of application programs that are started subsequently. 
  189. It does not help application programs already running.
  190.  
  191.    On some systems, including BSD 4.3, all programs using a terminal get
  192. a signal named `SIGWINCH' whenever the screen size changes. Programs
  193. that use termcap should handle this signal by using `ioctl TIOCGWINSZ'
  194. to learn the new screen size.
  195.  
  196. `co'
  197.      Numeric value, the width of the screen in character positions. 
  198.      Even hardcopy terminals normally have a `co' capability.
  199.  
  200. `li'
  201.      Numeric value, the height of the screen in lines.
  202.  
  203. 
  204. File: termcap,  Node: Cursor Motion,  Next: Wrapping,  Prev: Screen Size,  Up: Capabilities
  205.  
  206. Cursor Motion
  207. =============
  208.  
  209.    Termcap assumes that the terminal has a "cursor", a spot on the
  210. screen where a visible mark is displayed, and that most display
  211. commands take effect at the position of the cursor.  It follows that
  212. moving the cursor to a specified location is very important.
  213.  
  214.    There are many terminal capabilities for different cursor motion
  215. operations.  A terminal description should define as many as possible,
  216. but most programs do not need to use most of them.  One capability,
  217. `cm', moves the cursor to an arbitrary place on the screen; this by
  218. itself is sufficient for any application as long as there is no need to
  219. support hardcopy terminals or certain old, weak displays that have only
  220. relative motion commands.  Use of other cursor motion capabilities is an
  221. optimization, enabling the program to output fewer characters in some
  222. common cases.
  223.  
  224.    If you plan to use the relative cursor motion commands in an
  225. application program, you must know what the starting cursor position
  226. is.  To do this, you must keep track of the cursor position and update
  227. the records each time anything is output to the terminal, including
  228. graphic characters. In addition, it is necessary to know whether the
  229. terminal wraps after writing in the rightmost column.  *Note Wrapping::.
  230.  
  231.    One other motion capability needs special mention: `nw' moves the
  232. cursor to the beginning of the following line, perhaps clearing all the
  233. starting line after the cursor, or perhaps not clearing at all.  This
  234. capability is a least common denominator that is probably supported
  235. even by terminals that cannot do most other things such as `cm' or `do'.
  236. Even hardcopy terminals can support `nw'.
  237.  
  238. `cm'
  239.      String of commands to position the cursor at line L, column C.
  240.      Both parameters are origin-zero, and are defined relative to the
  241.      screen, not relative to display memory.
  242.  
  243.      All display terminals except a few very obsolete ones support `cm',
  244.      so it is acceptable for an application program to refuse to
  245.      operate on terminals lacking `cm'.
  246.  
  247. `ho'
  248.      String of commands to move the cursor to the upper left corner of
  249.      the screen (this position is called the "home position").  In
  250.      terminals where the upper left corner of the screen is not the
  251.      same as the beginning of display memory, this command must go to
  252.      the upper left corner of the screen, not the beginning of display
  253.      memory.
  254.  
  255.      Every display terminal supports this capability, and many
  256.      application programs refuse to operate if the `ho' capability is
  257.      missing.
  258.  
  259. `ll'
  260.      String of commands to move the cursor to the lower left corner of
  261.      the screen.  On some terminals, moving up from home position does
  262.      this, but programs should never assume that will work.  Just
  263.      output the `ll' string (if it is provided); if moving to home
  264.      position and then moving up is the best way to get there, the `ll'
  265.      command will do that.
  266.  
  267. `cr'
  268.      String of commands to move the cursor to the beginning of the line
  269.      it is on.  If this capability is not specified, many programs
  270.      assume they can use the ASCII carriage return character for this.
  271.  
  272. `le'
  273.      String of commands to move the cursor left one column.  Unless the
  274.      `bw' flag capability is specified, the effect is undefined if the
  275.      cursor is at the left margin; do not use this command there.  If
  276.      `bw' is present, this command may be used at the left margin, and
  277.      it wraps the cursor to the last column of the preceding line.
  278.  
  279. `nd'
  280.      String of commands to move the cursor right one column.  The
  281.      effect is undefined if the cursor is at the right margin; do not
  282.      use this command there, not even if `am' is present.
  283.  
  284. `up'
  285.      String of commands to move the cursor vertically up one line.  The
  286.      effect of sending this string when on the top line is undefined;
  287.      programs should never use it that way.
  288.  
  289. `do'
  290.      String of commands to move the cursor vertically down one line. 
  291.      The effect of sending this string when on the bottom line is
  292.      undefined; programs should never use it that way.
  293.  
  294.      The original idea was that this string would not contain a newline
  295.      character and therefore could be used without disabling the
  296.      kernel's usual habit of converting of newline into a
  297.      carriage-return newline sequence. But many terminal descriptions
  298.      do use newline in the `do' string, so this is not possible; a
  299.      program which sends the `do' string must disable output conversion
  300.      in the kernel (*note Initialize::.).
  301.  
  302. `bw'
  303.      Flag whose presence says that `le' may be used in column zero to
  304.      move to the last column of the preceding line.  If this flag is
  305.      not present, `le' should not be used in column zero.
  306.  
  307. `nw'
  308.      String of commands to move the cursor to start of next line,
  309.      possibly clearing rest of line (following the cursor) before
  310.      moving.
  311.  
  312. `DO', `UP', `LE', `RI'
  313.      Strings of commands to move the cursor N lines down vertically, up
  314.      vertically, or N columns left or right.  Do not attempt to move
  315.      past any edge of the screen with these commands; the effect of
  316.      trying that is undefined.  Only a few terminal descriptions provide
  317.      these commands, and most programs do not use them.
  318.  
  319. `CM'
  320.      String of commands to position the cursor at line L, column C,
  321.      relative to display memory.  Both parameters are origin-zero. This
  322.      capability is present only in terminals where there is a
  323.      difference between screen-relative and memory-relative addressing,
  324.      and not even in all such terminals.
  325.  
  326. `ch'
  327.      String of commands to position the cursor at column C in the same
  328.      line it is on.  This is a special case of `cm' in which the
  329.      vertical position is not changed.  The `ch' capability is provided
  330.      only when it is faster to output than `cm' would be in this
  331.      special case.  Programs should not assume most display terminals
  332.      have `ch'.
  333.  
  334. `cv'
  335.      String of commands to position the cursor at line L in the same
  336.      column.  This is a special case of `cm' in which the horizontal
  337.      position is not changed.  The `cv' capability is provided only
  338.      when it is faster to output than `cm' would be in this special
  339.      case.  Programs should not assume most display terminals have `cv'.
  340.  
  341. `sc'
  342.      String of commands to make the terminal save the current cursor
  343.      position.  Only the last saved position can be used.  If this
  344.      capability is present, `rc' should be provided also.  Most
  345.      terminals have neither.
  346.  
  347. `rc'
  348.      String of commands to make the terminal restore the last saved
  349.      cursor position.  If this capability is present, `sc' should be
  350.      provided also.  Most terminals have neither.
  351.  
  352. `ff'
  353.      String of commands to advance to the next page, for a hardcopy
  354.      terminal.
  355.  
  356. `ta'
  357.      String of commands to move the cursor right to the next hardware
  358.      tab stop column.  Missing if the terminal does not have any kind of
  359.      hardware tabs.  Do not send this command if the kernel's terminal
  360.      modes say that the kernel is expanding tabs into spaces.
  361.  
  362. `bt'
  363.      String of commands to move the cursor left to the previous hardware
  364.      tab stop column.  Missing if the terminal has no such ability; many
  365.      terminals do not.  Do not send this command if the kernel's
  366.      terminal modes say that the kernel is expanding tabs into spaces.
  367.  
  368.    The following obsolete capabilities should be included in terminal
  369. descriptions when appropriate, but should not be looked at by new
  370. programs.
  371.  
  372. `nc'
  373.      Flag whose presence means the terminal does not support the ASCII
  374.      carriage return character as `cr'.  This flag is needed because
  375.      old programs assume, when the `cr' capability is missing, that
  376.      ASCII carriage return can be used for the purpose.  We use `nc' to
  377.      tell the old programs that carriage return may not be used.
  378.  
  379.      New programs should not assume any default for `cr', so they need
  380.      not look at `nc'.  However, descriptions should contain `nc'
  381.      whenever they do not contain `cr'.
  382.  
  383. `xt'
  384.      Flag whose presence means that the ASCII tab character may not be
  385.      used for cursor motion.  This flag exists because old programs
  386.      assume, when the `ta' capability is missing, that ASCII tab can be
  387.      used for the purpose.  We use `xt' to tell the old programs not to
  388.      use tab.
  389.  
  390.      New programs should not assume any default for `ta', so they need
  391.      not look at `xt' in connection with cursor motion.  Note that `xt'
  392.      also has implications for standout mode (*note Standout::.). It is
  393.      obsolete in regard to cursor motion but not in regard to standout.
  394.  
  395.      In fact, `xt' means that the terminal is a Teleray 1061.
  396.  
  397. `bc'
  398.      Very obsolete alternative name for the `le' capability.
  399.  
  400. `bs'
  401.      Flag whose presence means that the ASCII character backspace may be
  402.      used to move the cursor left.  Obsolete; look at `le' instead.
  403.  
  404. `nl'
  405.      Obsolete capability which is a string that can either be used to
  406.      move the cursor down or to scroll.  The same string must scroll
  407.      when used on the bottom line and move the cursor when used on any
  408.      other line. New programs should use `do' or `sf', and ignore `nl'.
  409.  
  410.      If there is no `nl' capability, some old programs assume they can
  411.      use the newline character for this purpose.  These programs follow
  412.      a bad practice, but because they exist, it is still desirable to
  413.      define the `nl' capability in a terminal description if the best
  414.      way to move down is *not* a newline.
  415.  
  416. 
  417. File: termcap,  Node: Wrapping,  Next: Scrolling,  Prev: Cursor Motion,  Up: Capabilities
  418.  
  419. Wrapping
  420. ========
  421.  
  422.    "Wrapping" means moving the cursor from the right margin to the left
  423. margin of the following line.  Some terminals wrap automatically when a
  424. graphic character is output in the last column, while others do not. 
  425. Most application programs that use termcap need to know whether the
  426. terminal wraps.  There are two special flag capabilities to describe
  427. what the terminal does when a graphic character is output in the last
  428. column.
  429.  
  430. `am'
  431.      Flag whose presence means that writing a character in the last
  432.      column causes the cursor to wrap to the beginning of the next line.
  433.  
  434.      If `am' is not present, writing in the last column leaves the
  435.      cursor at the place where the character was written.
  436.  
  437.      Writing in the last column of the last line should be avoided on
  438.      terminals with `am', as it may or may not cause scrolling to occur
  439.      (*note Scrolling::.).  Scrolling is surely not what you would
  440.      intend.
  441.  
  442.      If your program needs to check the `am' flag, then it also needs
  443.      to check the `xn' flag which indicates that wrapping happens in a
  444.      strange way.  Many common terminals have the `xn' flag.
  445.  
  446. `xn'
  447.      Flag whose presence means that the cursor wraps in a strange way. 
  448.      At least two distinct kinds of strange behavior are known; the
  449.      termcap data base does not contain anything to distinguish the two.
  450.  
  451.      On Concept-100 terminals, output in the last column wraps the
  452.      cursor almost like an ordinary `am' terminal.  But if the next
  453.      thing output is a newline, it is ignored.
  454.  
  455.      DEC VT-100 terminals (when the wrap switch is on) do a different
  456.      strange thing: the cursor wraps only if the next thing output is
  457.      another graphic character.  In fact, the wrap occurs when the
  458.      following graphic character is received by the terminal, before the
  459.      character is placed on the screen.
  460.  
  461.      On both of these terminals, after writing in the last column a
  462.      following graphic character will be displayed in the first column
  463.      of the following line.  But the effect of relative cursor motion
  464.      characters such as newline or backspace at such a time depends on
  465.      the terminal.  The effect of erase or scrolling commands also
  466.      depends on the terminal.  You can't assume anything about what
  467.      they will do on a terminal that has `xn'.  So, to be safe, you
  468.      should never do these things at such a time on such a terminal.
  469.  
  470.      To be sure of reliable results on a terminal which has the `xn'
  471.      flag, output a `cm' absolute positioning command after writing in
  472.      the last column.  Another safe thing to do is to output
  473.      carriage-return newline, which will leave the cursor at the
  474.      beginning of the following line.
  475.  
  476. 
  477. File: termcap,  Node: Scrolling,  Next: Windows,  Prev: Wrapping,  Up: Capabilities
  478.  
  479. Scrolling
  480. =========
  481.  
  482.    "Scrolling" means moving the contents of the screen up or down one or
  483. more lines.  Moving the contents up is "forward scrolling"; moving them
  484. down is "reverse scrolling".
  485.  
  486.    Scrolling happens after each line of output during ordinary output
  487. on most display terminals.  But in an application program that uses
  488. termcap for random-access output, scrolling happens only when
  489. explicitly requested with the commands in this section.
  490.  
  491.    Some terminals have a "scroll region" feature.  This lets you limit
  492. the effect of scrolling to a specified range of lines.  Lines outside
  493. the range are unaffected when scrolling happens.  The scroll region
  494. feature is available if either `cs' or `cS' is present.
  495.  
  496. `sf'
  497.      String of commands to scroll the screen one line up, assuming it is
  498.      output with the cursor at the beginning of the bottom line.
  499.  
  500. `sr'
  501.      String of commands to scroll the screen one line down, assuming it
  502.      is output with the cursor at the beginning of the top line.
  503.  
  504. `SF'
  505.      String of commands to scroll the screen N lines up, assuming it is
  506.      output with the cursor at the beginning of the bottom line.
  507.  
  508. `SR'
  509.      String of commands to scroll the screen N line down, assuming it
  510.      is output with the cursor at the beginning of the top line.
  511.  
  512. `cs'
  513.      String of commands to set the scroll region.  This command takes
  514.      two parameters, START and END, which are the line numbers
  515.      (origin-zero) of the first line to include in the scroll region
  516.      and of the last line to include in it.  When a scroll region is
  517.      set, scrolling is limited to the specified range of lines; lines
  518.      outside the range are not affected by scroll commands.
  519.  
  520.      Do not try to move the cursor outside the scroll region.  The
  521.      region remains set until explicitly removed.  To remove the scroll
  522.      region, use another `cs' command specifying the full height of the
  523.      screen.
  524.  
  525.      The cursor position is undefined after the `cs' command is set, so
  526.      position the cursor with `cm' immediately afterward.
  527.  
  528. `cS'
  529.      String of commands to set the scroll region using parameters in
  530.      different form.  The effect is the same as if `cs' were used. Four
  531.      parameters are required:
  532.  
  533.        1. Total number of lines on the screen.
  534.  
  535.        2. Number of lines above desired scroll region.
  536.  
  537.        3. Number of lines below (outside of) desired scroll region.
  538.  
  539.        4. Total number of lines on the screen, the same as the first
  540.           parameter.
  541.  
  542.      This capability is a GNU extension that was invented to allow the
  543.      Ann Arbor Ambassador's scroll-region command to be described; it
  544.      could also be done by putting non-Unix `%'-sequences into a `cs'
  545.      string, but that would have confused Unix programs that used the
  546.      `cs' capability with the Unix termcap.  Currently only GNU Emacs
  547.      uses the `cS' capability.
  548.  
  549. `ns'
  550.      Flag which means that the terminal does not normally scroll for
  551.      ordinary sequential output.  For modern terminals, this means that
  552.      outputting a newline in ordinary sequential output with the cursor
  553.      on the bottom line wraps to the top line.  For some obsolete
  554.      terminals, other things may happen.
  555.  
  556.      The terminal may be able to scroll even if it does not normally do
  557.      so. If the `sf' capability is provided, it can be used for
  558.      scrolling regardless of `ns'.
  559.  
  560. `da'
  561.      Flag whose presence means that lines scrolled up off the top of the
  562.      screen may come back if scrolling down is done subsequently.
  563.  
  564.      The `da' and `db' flags do not, strictly speaking, affect how to
  565.      scroll.  But programs that scroll usually need to clear the lines
  566.      scrolled onto the screen, if these flags are present.
  567.  
  568. `db'
  569.      Flag whose presence means that lines scrolled down off the bottom
  570.      of the screen may come back if scrolling up is done subsequently.
  571.  
  572. `lm'
  573.      Numeric value, the number of lines of display memory that the
  574.      terminal has.  A value of zero means that the terminal has more
  575.      display memory than can fit on the screen, but no fixed number of
  576.      lines.  (The number of lines may depend on the amount of text in
  577.      each line.)
  578.  
  579.    Any terminal description that defines `SF' should also define `sf';
  580. likewise for `SR' and `sr'.  However, many terminals can only scroll by
  581. one line at a time, so it is common to find `sf' and not `SF', or `sr'
  582. without `SR'.
  583.  
  584.    Therefore, all programs that use the scrolling facilities should be
  585. prepared to work with `sf' in the case that `SF' is absent, and
  586. likewise with `sr'.  On the other hand, an application program that
  587. uses only `sf' and not `SF' is acceptable, though slow on some
  588. terminals.
  589.  
  590.    When outputting a scroll command with `tputs', the NLINES argument
  591. should be the total number of lines in the portion of the screen being
  592. scrolled.  Very often these commands require padding proportional to
  593. this number of lines.  *Note Padding::.
  594.  
  595. 
  596. File: termcap,  Node: Windows,  Next: Clearing,  Prev: Scrolling,  Up: Capabilities
  597.  
  598. Windows
  599. =======
  600.  
  601.    A "window", in termcap, is a rectangular portion of the screen to
  602. which all display operations are restricted.  Wrapping, clearing,
  603. scrolling, insertion and deletion all operate as if the specified
  604. window were all the screen there was.
  605.  
  606. `wi'
  607.      String of commands to set the terminal output screen window. This
  608.      string requires four parameters, all origin-zero:
  609.        1. The first line to include in the window.
  610.  
  611.        2. The last line to include in the window.
  612.  
  613.        3. The first column to include in the window.
  614.  
  615.        4. The last column to include in the window.
  616.  
  617.    Most terminals do not support windows.
  618.  
  619. 
  620. File: termcap,  Node: Clearing,  Next: Insdel Line,  Prev: Windows,  Up: Capabilities
  621.  
  622. Clearing Parts of the Screen
  623. ============================
  624.  
  625.    There are several terminal capabilities for clearing parts of the
  626. screen to blank.  All display terminals support the `cl' string, and
  627. most display terminals support all of these capabilities.
  628.  
  629. `cl'
  630.      String of commands to clear the entire screen and position the
  631.      cursor at the upper left corner.
  632.  
  633. `cd'
  634.      String of commands to clear the line the cursor is on, and all the
  635.      lines below it, down to the bottom of the screen.  This command
  636.      string should be used only with the cursor in column zero; their
  637.      effect is undefined if the cursor is elsewhere.
  638.  
  639. `ce'
  640.      String of commands to clear from the cursor to the end of the
  641.      current line.
  642.  
  643. `ec'
  644.      String of commands to clear N characters, starting with the
  645.      character that the cursor is on.  This command string is expected
  646.      to leave the cursor position unchanged.  The parameter N should
  647.      never be large enough to reach past the right margin; the effect
  648.      of such a large parameter would be undefined.
  649.  
  650.    Clear to end of line (`ce') is extremely important in programs that
  651. maintain an updating display.  Nearly all display terminals support this
  652. operation, so it is acceptable for a an application program to refuse to
  653. work if `ce' is not present.  However, if you do not want this
  654. limitation, you can accomplish clearing to end of line by outputting
  655. spaces until you reach the right margin.  In order to do this, you must
  656. know the current horizontal position.  Also, this technique assumes
  657. that writing a space will erase.  But this happens to be true on all
  658. the display terminals that fail to support `ce'.
  659.  
  660. 
  661. File: termcap,  Node: Insdel Line,  Next: Insdel Char,  Prev: Clearing,  Up: Capabilities
  662.  
  663. Insert/Delete Line
  664. ==================
  665.  
  666.    "Inserting a line" means creating a blank line in the middle of the
  667. screen, and pushing the existing lines of text apart.  In fact, the
  668. lines above the insertion point do not change, while the lines below
  669. move down, and one is normally lost at the bottom of the screen.
  670.  
  671.    "Deleting a line" means causing the line to disappear from the
  672. screen, closing up the gap by moving the lines below it upward.  A new
  673. line appears at the bottom of the screen.  Usually this line is blank,
  674. but on terminals with the `db' flag it may be a line previously moved
  675. off the screen bottom by scrolling or line insertion.
  676.  
  677.    Insertion and deletion of lines is useful in programs that maintain
  678. an updating display some parts of which may get longer or shorter. 
  679. They are also useful in editors for scrolling parts of the screen, and
  680. for redisplaying after lines of text are killed or inserted.
  681.  
  682.    Many terminals provide commands to insert or delete a single line at
  683. the cursor position.  Some provide the ability to insert or delete
  684. several lines with one command, using the number of lines to insert or
  685. delete as a parameter.  Always move the cursor to column zero before
  686. using any of these commands.
  687.  
  688. `al'
  689.      String of commands to insert a blank line before the line the
  690.      cursor is on.  The existing line, and all lines below it, are
  691.      moved down. The last line in the screen (or in the scroll region,
  692.      if one is set) disappears and in most circumstances is discarded. 
  693.      It may not be discarded if the `db' is present (*note
  694.      Scrolling::.).
  695.  
  696.      The cursor must be at the left margin before this command is used.
  697.      This command does not move the cursor.
  698.  
  699. `dl'
  700.      String of commands to delete the line the cursor is on.  The
  701.      following lines move up, and a blank line appears at the bottom of
  702.      the screen (or bottom of the scroll region).  If the terminal has
  703.      the `db' flag, a nonblank line previously pushed off the screen
  704.      bottom may reappear at the bottom.
  705.  
  706.      The cursor must be at the left margin before this command is used.
  707.      This command does not move the cursor.
  708.  
  709. `AL'
  710.      String of commands to insert N blank lines before the line that
  711.      the cursor is on.  It is like `al' repeated N times, except that
  712.      it is as fast as one `al'.
  713.  
  714. `DL'
  715.      String of commands to delete N lines starting with the line that
  716.      the cursor is on.  It is like `dl' repeated N times, except that
  717.      it is as fast as one `dl'.
  718.  
  719.    Any terminal description that defines `AL' should also define `al';
  720. likewise for `DL' and `dl'.  However, many terminals can only insert or
  721. delete one line at a time, so it is common to find `al' and not `AL',
  722. or `dl' without `DL'.
  723.  
  724.    Therefore, all programs that use the insert and delete facilities
  725. should be prepared to work with `al' in the case that `AL' is absent,
  726. and likewise with `dl'.  On the other hand, it is acceptable to write
  727. an application that uses only `al' and `dl' and does not look for `AL'
  728. or `DL' at all.
  729.  
  730.    If a terminal does not support line insertion and deletion directly,
  731. but does support a scroll region, the effect of insertion and deletion
  732. can be obtained with scrolling.  However, it is up to the individual
  733. user program to check for this possibility and use the scrolling
  734. commands to get the desired result.  It is fairly important to implement
  735. this alternate strategy, since it is the only way to get the effect of
  736. line insertion and deletion on the popular VT100 terminal.
  737.  
  738.    Insertion and deletion of lines is affected by the scroll region on
  739. terminals that have a settable scroll region.  This is useful when it is
  740. desirable to move any few consecutive lines up or down by a few lines.
  741. *Note Scrolling::.
  742.  
  743.    The line pushed off the bottom of the screen is not lost if the
  744. terminal has the `db' flag capability; instead, it is pushed into
  745. display memory that does not appear on the screen.  This is the same
  746. thing that happens when scrolling pushes a line off the bottom of the
  747. screen. Either reverse scrolling or deletion of a line can bring the
  748. apparently lost line back onto the bottom of the screen.  If the
  749. terminal has the scroll region feature as well as `db', the pushed-out
  750. line really is lost if a scroll region is in effect.
  751.  
  752.    When outputting an insert or delete command with `tputs', the NLINES
  753. argument should be the total number of lines from the cursor to the
  754. bottom of the screen (or scroll region).  Very often these commands
  755. require padding proportional to this number of lines.  *Note Padding::.
  756.  
  757.    For `AL' and `DL' the NLINES argument should *not* depend on the
  758. number of lines inserted or deleted; only the total number of lines
  759. affected.  This is because it is just as fast to insert two or N lines
  760. with `AL' as to insert one line with `al'.
  761.  
  762. 
  763. File: termcap,  Node: Insdel Char,  Next: Standout,  Prev: Insdel Line,  Up: Capabilities
  764.  
  765. Insert/Delete Character
  766. =======================
  767.  
  768.    "Inserting a character" means creating a blank space in the middle
  769. of a line, and pushing the rest of the line rightward.  The character
  770. in the rightmost column is lost.
  771.  
  772.    "Deleting a character" means causing the character to disappear from
  773. the screen, closing up the gap by moving the rest of the line leftward.
  774.  A blank space appears in the rightmost column.
  775.  
  776.    Insertion and deletion of characters is useful in programs that
  777. maintain an updating display some parts of which may get longer or
  778. shorter.  It is also useful in editors for redisplaying the results of
  779. editing within a line.
  780.  
  781.    Many terminals provide commands to insert or delete a single
  782. character at the cursor position.  Some provide the ability to insert
  783. or delete several characters with one command, using the number of
  784. characters to insert or delete as a parameter.
  785.  
  786.    Many terminals provide an insert mode in which outputting a graphic
  787. character has the added effect of inserting a position for that
  788. character. A special command string is used to enter insert mode and
  789. another is used to exit it.  The reason for designing a terminal with
  790. an insert mode rather than an insert command is that inserting
  791. character positions is usually followed by writing characters into
  792. them.  With insert mode, this is as fast as simply writing the
  793. characters, except for the fixed overhead of entering and leaving
  794. insert mode.  However, when the line speed is great enough, padding may
  795. be required for the graphic characters output in insert mode.
  796.  
  797.    Some terminals require you to enter insert mode and then output a
  798. special command for each position to be inserted.  Or they may require
  799. special commands to be output before or after each graphic character to
  800. be inserted.
  801.  
  802.    Deletion of characters is usually accomplished by a straightforward
  803. command to delete one or several positions; but on some terminals, it
  804. is necessary to enter a special delete mode before using the delete
  805. command, and leave delete mode afterward.  Sometimes delete mode and
  806. insert mode are the same mode.
  807.  
  808.    Some terminals make a distinction between character positions in
  809. which a space character has been output and positions which have been
  810. cleared.  On these terminals, the effect of insert or delete character
  811. runs to the first cleared position rather than to the end of the line. 
  812. In fact, the effect may run to more than one line if there is no
  813. cleared position to stop the shift on the first line.  These terminals
  814. are identified by the `in' flag capability.
  815.  
  816.    On terminals with the `in' flag, the technique of skipping over
  817. characters that you know were cleared, and then outputting text later
  818. on in the same line, causes later insert and delete character
  819. operations on that line to do nonstandard things.  A program that has
  820. any chance of doing this must check for the `in' flag and must be
  821. careful to write explicit space characters into the intermediate
  822. columns when `in' is present.
  823.  
  824.    A plethora of terminal capabilities are needed to describe all of
  825. this complexity.  Here is a list of them all.  Following the list, we
  826. present an algorithm for programs to use to take proper account of all
  827. of these capabilities.
  828.  
  829. `im'
  830.      String of commands to enter insert mode.
  831.  
  832.      If the terminal has no special insert mode, but it can insert
  833.      characters with a special command, `im' should be defined with a
  834.      null value, because the `vi' editor assumes that insertion of a
  835.      character is impossible if `im' is not provided.
  836.  
  837.      New programs should not act like `vi'.  They should pay attention
  838.      to `im' only if it is defined.
  839.  
  840. `ei'
  841.      String of commands to leave insert mode.  This capability must be
  842.      present if `im' is.
  843.  
  844.      On a few old terminals the same string is used to enter and exit
  845.      insert mode.  This string turns insert mode on if it was off, and
  846.      off it it was on.  You can tell these terminals because the `ei'
  847.      string equals the `im' string.  If you want to support these
  848.      terminals, you must always remember accurately whether insert mode
  849.      is in effect.  However, these terminals are obsolete, and it is
  850.      reasonable to refuse to support them.  On all modern terminals, you
  851.      can safely output `ei' at any time to ensure that insert mode is
  852.      turned off.
  853.  
  854. `ic'
  855.      String of commands to insert one character position at the cursor.
  856.      The cursor does not move.
  857.  
  858.      If outputting a graphic character while in insert mode is
  859.      sufficient to insert the character, then the `ic' capability
  860.      should be defined with a null value.
  861.  
  862.      If your terminal offers a choice of ways to insert--either use
  863.      insert mode or use a special command--then define `im' and do not
  864.      define `ic', since this gives the most efficient operation when
  865.      several characters are to be inserted.  *Do not* define both
  866.      strings, for that means that *both* must be used each time
  867.      insertion is done.
  868.  
  869. `ip'
  870.      String of commands to output following an inserted graphic
  871.      character in insert mode.  Often it is used just for a padding
  872.      spec, when padding is needed after an inserted character (*note
  873.      Padding::.).
  874.  
  875. `IC'
  876.      String of commands to insert N character positions at and after
  877.      the cursor.  It has the same effect as repeating the `ic' string
  878.      and a space, N times.
  879.  
  880.      If `IC' is provided, application programs may use it without first
  881.      entering insert mode.
  882.  
  883. `mi'
  884.      Flag whose presence means it is safe to move the cursor while in
  885.      insert mode and assume the terminal remains in insert mode.
  886.  
  887. `in'
  888.      Flag whose presence means that the terminal distinguishes between
  889.      character positions in which space characters have been output and
  890.      positions which have been cleared.
  891.  
  892.    An application program can assume that the terminal can do character
  893. insertion if *any one of* the capabilities `IC', `im', `ic' or `ip' is
  894. provided.
  895.  
  896.    To insert N blank character positions, move the cursor to the place
  897. to insert them and follow this algorithm:
  898.  
  899.   1. If an `IC' string is provided, output it with parameter N and you
  900.      are finished.  Otherwise (or if you don't want to bother to look
  901.      for an `IC' string) follow the remaining steps.
  902.  
  903.   2. Output the `im' string, if there is one, unless the terminal is
  904.      already in insert mode.
  905.  
  906.   3. Repeat steps 4 through 6, N times.
  907.  
  908.   4. Output the `ic' string if any.
  909.  
  910.   5. Output a space.
  911.  
  912.   6. Output the `ip' string if any.
  913.  
  914.   7. Output the `ei' string, eventually, to exit insert mode.  There is
  915.      no need to do this right away.  If the `mi' flag is present, you
  916.      can move the cursor and the cursor will remain in insert mode;
  917.      then you can do more insertion elsewhere without reentering insert
  918.      mode.
  919.  
  920.    To insert N graphic characters, position the cursor and follow this
  921. algorithm:
  922.  
  923.   1. If an `IC' string is provided, output it with parameter N, then
  924.      output the graphic characters, and you are finished.  Otherwise
  925.      (or if you don't want to bother to look for an `IC' string) follow
  926.      the remaining steps.
  927.  
  928.   2. Output the `im' string, if there is one, unless the terminal is
  929.      already in insert mode.
  930.  
  931.   3. For each character to be output, repeat steps 4 through 6.
  932.  
  933.   4. Output the `ic' string if any.
  934.  
  935.   5. Output the next graphic character.
  936.  
  937.   6. Output the `ip' string if any.
  938.  
  939.   7. Output the `ei' string, eventually, to exit insert mode.  There is
  940.      no need to do this right away.  If the `mi' flag is present, you
  941.      can move the cursor and the cursor will remain in insert mode;
  942.      then you can do more insertion elsewhere without reentering insert
  943.      mode.
  944.  
  945.    Note that this is not the same as the original Unix termcap
  946. specifications in one respect: it assumes that the `IC' string can be
  947. used without entering insert mode.  This is true as far as I know, and
  948. it allows you be able to avoid entering and leaving insert mode, and
  949. also to be able to avoid the inserted-character padding after the
  950. characters that go into the inserted positions.
  951.  
  952.    Deletion of characters is less complicated; deleting one column is
  953. done by outputting the `dc' string.  However, there may be a delete
  954. mode that must be entered with `dm' in order to make `dc' work.
  955.  
  956. `dc'
  957.      String of commands to delete one character position at the cursor.
  958.       If `dc' is not present, the terminal cannot delete characters.
  959.  
  960. `DC'
  961.      String of commands to delete N characters starting at the cursor.
  962.      It has the same effect as repeating the `dc' string N times. Any
  963.      terminal description that has `DC' also has `dc'.
  964.  
  965. `dm'
  966.      String of commands to enter delete mode.  If not present, there is
  967.      no delete mode, and `dc' can be used at any time (assuming there is
  968.      a `dc').
  969.  
  970. `ed'
  971.      String of commands to exit delete mode.  This must be present if
  972.      `dm' is.
  973.  
  974.    To delete N character positions, position the cursor and follow these
  975. steps:
  976.  
  977.   1. If the `DC' string is present, output it with parameter N and you
  978.      are finished.  Otherwise, follow the remaining steps.
  979.  
  980.   2. Output the `dm' string, unless you know the terminal is already in
  981.      delete mode.
  982.  
  983.   3. Output the `dc' string N times.
  984.  
  985.   4. Output the `ed' string eventually.  If the flag capability `mi' is
  986.      present, you can move the cursor and do more deletion without
  987.      leaving and reentering delete mode.
  988.  
  989.    As with the `IC' string, we have departed from the original termcap
  990. specifications by assuming that `DC' works without entering delete mode
  991. even though `dc' would not.
  992.  
  993.    If the `dm' and `im' capabilities are both present and have the same
  994. value, it means that the terminal has one mode for both insertion and
  995. deletion.  It is useful for a program to know this, because then it can
  996. do insertions after deletions, or vice versa, without leaving
  997. insert/delete mode and reentering it.
  998.  
  999.