public void eraseInDisplay()

in core/src/com/jediterm/terminal/model/JediTerminal.java [372:421]


  public void eraseInDisplay(final int arg) {
    // ED (Erase in Display) https://vt100.net/docs/vt510-rm/ED.html
    myTerminalTextBuffer.lock();
    try {
      int beginY;
      int endY;

      switch (arg) {
        case 0:
          // Initial line
          if (myCursorX < myTerminalWidth) {
            myTerminalTextBuffer.eraseCharacters(myCursorX, -1, myCursorY - 1);
          }
          // Rest
          beginY = myCursorY;
          endY = myTerminalHeight - 1;

          break;
        case 1:
          // initial line
          myTerminalTextBuffer.eraseCharacters(0, myCursorX + 1, myCursorY - 1);

          beginY = 0;
          endY = myCursorY - 1;
          break;
        case 2:
          beginY = 0;
          endY = myTerminalHeight - 1;
          myTerminalTextBuffer.moveScreenLinesToHistory();
          break;
        case 3:
          // Clear entire screen and delete all lines saved in the scrollback buffer (xterm).
          // https://en.wikipedia.org/wiki/ANSI_escape_code#CSIsection
          // `clear` command emits it, and the scroll buffer is expected to be cleared as a result.
          beginY = 0;
          endY = myTerminalHeight - 1;
          myTerminalTextBuffer.clearHistory();
          break;
        default:
          LOG.warn("Unsupported erase in display mode:" + arg);
          beginY = 1;
          endY = 1;
          break;
      }
      // Rest of lines
      clearLines(beginY, endY);
    } finally {
      myTerminalTextBuffer.unlock();
    }
  }