down method

String? down()

Scroll 'down' -- Replace the user-input buffer with the contents of the next line. The final 'next line' is the original contents of the line buffer.

Implementation

String? down() {
  // Handle the case of the user tapping 'down' before there is a
  // scrollback buffer to scroll through.
  if (lineIndex == null) {
    return null;
  } else {
    lineIndex = lineIndex! + 1;
    lineIndex = lineIndex! > lineList.length ? lineList.length : lineIndex;
    if (lineIndex == lineList.length) {
      // Once the user scrolls to the bottom, reset the current line
      // buffer so that up() can store it again: The user might have
      // edited it between down() and up().
      final temp = currentLineBuffer;
      currentLineBuffer = null;
      return temp;
    } else {
      return lineList[lineIndex!];
    }
  }
}