home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / termcap.i02 (.txt) < prev    next >
GNU Info File  |  1993-06-14  |  45KB  |  717 lines

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