private void addLine()

in core/src/com/jediterm/terminal/model/ChangeWidthOperation.java [141:177]


  private void addLine(@NotNull TerminalLine line) {
    if (line.isNul()) {
      if (myCurrentLine != null) {
        myCurrentLine = null;
        myCurrentLineLength = 0;
      }
      myAllLines.add(TerminalLine.createEmpty());
      return;
    }
    line.forEachEntry(entry -> {
      if (entry.isNul()) {
        return;
      }
      int entryProcessedLength = 0;
      while (entryProcessedLength < entry.getLength()) {
        if (myCurrentLine != null && myCurrentLineLength == myNewWidth) {
          myCurrentLine.setWrapped(true);
          myCurrentLine = null;
          myCurrentLineLength = 0;
        }
        if (myCurrentLine == null) {
          myCurrentLine = new TerminalLine();
          myCurrentLineLength = 0;
          myAllLines.add(myCurrentLine);
        }
        int len = Math.min(myNewWidth - myCurrentLineLength, entry.getLength() - entryProcessedLength);
        TerminalLine.TextEntry newEntry = subEntry(entry, entryProcessedLength, len);
        myCurrentLine.appendEntry(newEntry);
        myCurrentLineLength += len;
        entryProcessedLength += len;
      }
    });
    if (!line.isWrapped()) {
      myCurrentLine = null;
      myCurrentLineLength = 0;
    }
  }