Inserting a line means creating a blank line in the middle of the screen, and pushing the existing lines of text apart. In fact, the lines above the insertion point do not change, while the lines below move down, and one is normally lost at the bottom of the screen.
Deleting a line means causing the line to disappear from the screen, closing up the gap by moving the lines below it upward. A new line appears at the bottom of the screen. Usually this line is blank, but on terminals with the `db' flag it may be a line previously moved off the screen bottom by scrolling or line insertion.
Insertion and deletion of lines is useful in programs that maintain an updating display some parts of which may get longer or shorter. They are also useful in editors for scrolling parts of the screen, and for redisplaying after lines of text are killed or inserted.
Many terminals provide commands to insert or delete a single line at the cursor position. Some provide the ability to insert or delete several lines with one command, using the number of lines to insert or delete as a parameter. Always move the cursor to column zero before using any of these commands.
Any terminal description that defines `AL' should also define `al'; likewise for `DL' and `dl'. However, many terminals can only insert or delete one line at a time, so it is common to find `al' and not `AL', or `dl' without `DL'.
Therefore, all programs that use the insert and delete facilities should be prepared to work with `al' in the case that `AL' is absent, and likewise with `dl'. On the other hand, it is acceptable to write an application that uses only `al' and `dl' and does not look for `AL' or `DL' at all.
If a terminal does not support line insertion and deletion directly, but does support a scroll region, the effect of insertion and deletion can be obtained with scrolling. However, it is up to the individual user program to check for this possibility and use the scrolling commands to get the desired result. It is fairly important to implement this alternate strategy, since it is the only way to get the effect of line insertion and deletion on the popular VT100 terminal.
Insertion and deletion of lines is affected by the scroll region on terminals that have a settable scroll region. This is useful when it is desirable to move any few consecutive lines up or down by a few lines. See section Scrolling.
The line pushed off the bottom of the screen is not lost if the terminal has the `db' flag capability; instead, it is pushed into display memory that does not appear on the screen. This is the same thing that happens when scrolling pushes a line off the bottom of the screen. Either reverse scrolling or deletion of a line can bring the apparently lost line back onto the bottom of the screen. If the terminal has the scroll region feature as well as `db', the pushed-out line really is lost if a scroll region is in effect.
When outputting an insert or delete command with tputs
, the
nlines argument should be the total number of lines from the cursor
to the bottom of the screen (or scroll region). Very often these commands
require padding proportional to this number of lines. See section Padding.
For `AL' and `DL' the nlines argument should not depend on the number of lines inserted or deleted; only the total number of lines affected. This is because it is just as fast to insert two or n lines with `AL' as to insert one line with `al'.
Go to the first, previous, next, last section, table of contents.