private void printText(@NotNull String text, @Nullable ConsoleViewContentType contentType) throws IOException {
    if (LOG.isTraceEnabled()) {
      LOG.trace("[" + Thread.currentThread().getName() + "] Print request received: " + CharUtils.toHumanReadableText(text));
    }
    Color foregroundColor = contentType != null ? contentType.getAttributes().getForegroundColor() : null;
    if (foregroundColor != null) {
      myDataStream.append(encodeColor(foregroundColor));
    }

    if (contentType != ConsoleViewContentType.SYSTEM_OUTPUT && myFirstOutput.compareAndSet(false, true) && startsWithClearScreen(text)) {
      LOG.trace("Clear Screen request detected at the beginning of the output, scheduling a scroll command.");
      // Windows ConPTY generates the 'clear screen' escape sequence (ESC[2J) optionally preceded by a "make cursor invisible" (ESC?25l) before the process output.
      // It pushes the already printed command line into the scrollback buffer which is not displayed by default.
      // In such cases, let's scroll up to display the printed command line.
      BoundedRangeModel verticalScrollModel = myTerminalWidget.getTerminalPanel().getVerticalScrollModel();
      verticalScrollModel.addChangeListener(new javax.swing.event.ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
          verticalScrollModel.removeChangeListener(this);
          UiNotifyConnector.doWhenFirstShown(myTerminalWidget.getTerminalPanel(), () -> {
            myTerminalWidget.getTerminalPanel().scrollToShowAllOutput();
          });
        }
      });
    }
    myDataStream.append(text);

    if (foregroundColor != null) {
      myDataStream.append((char)Ascii.ESC + "[39m"); //restore default foreground color
    }
    myContentHelper.onContentTypePrinted(text, ObjectUtils.notNull(contentType, ConsoleViewContentType.NORMAL_OUTPUT));
  }
private void printText(@NotNull String text, @Nullable ConsoleViewContentType contentType)