insertLines method
void
insertLines(
- int count
)
Implementation
void insertLines(int count) {
if (!isInVerticalMargin || !isInHorizontalMargin) {
return;
}
setCursorX(_marginLeft);
// Number of lines from the cursor to the bottom of the scrollable region
// including the cursor itself.
final linesBelow = absoluteMarginBottom - absoluteCursorY + 1;
// Number of empty lines to insert.
final linesToInsert = min(count, linesBelow);
// Number of lines to move up.
final linesToMove = linesBelow - linesToInsert;
if (!_usesFullHorizontalMargins) {
final width = _marginRight - _marginLeft + 1;
for (var i = 0; i < linesToMove; i++) {
final index = absoluteMarginBottom - i;
lines[index].copyFrom(
lines[index - linesToInsert],
_marginLeft,
_marginLeft,
width,
);
}
for (var i = 0; i < linesToInsert; i++) {
lines[absoluteCursorY + i].eraseRange(
_marginLeft,
_marginRight + 1,
terminal.cursor,
);
}
return;
}
for (var i = 0; i < linesToMove; i++) {
final index = absoluteMarginBottom - i;
lines[index] = lines.swap(index - linesToInsert, _newEmptyLine());
}
for (var i = linesToMove; i < linesToInsert; i++) {
lines[absoluteCursorY + i] = _newEmptyLine();
}
}