index method
void
index()
https://vt100.net/docs/vt100-ug/chapter3.html#IND IND – Index
ESC D
index causes the active position to move downward one line without changing the column position. If the active position is at the bottom margin, a scroll up is performed.
Implementation
void index() {
if (isInVerticalMargin) {
if (!isInHorizontalMarginOrPendingWrap) return;
if (_cursorY == _marginBottom) {
// scrollUp() already pushes new lines onto the scrollback when the
// margins cover the whole viewport; inserting a line here instead
// would leave a partial scroll region unscrolled and shift every row
// below the bottom margin down.
scrollUp(1);
} else {
moveCursorY(1);
}
return;
}
// the cursor is not in the scrollable region
if (_cursorY >= viewHeight - 1) {
// we are at the bottom
if (isAltBuffer) {
scrollUp(1);
} else {
lines.push(_newEmptyLine());
}
} else {
// there're still lines so we simply move cursor down.
moveCursorY(1);
}
}