home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / emacs / info / termcap-2 (.txt) < prev    next >
GNU Info File  |  1992-10-30  |  44KB  |  721 lines

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