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 (_cursorY == _marginBottom) {
if (marginTop == 0 && !isAltBuffer) {
lines.insert(absoluteMarginBottom + 1, _newEmptyLine());
} else {
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);
}
}