public final void attachToProcess(@NotNull ProcessHandler processHandler,
                                    @NotNull TtyConnector ttyConnector,
                                    boolean attachToProcessOutput) {
    if (!myAttachedToProcess.compareAndSet(false, true)) {
      return;
    }
    myTerminalWidget.createTerminalSession(ttyConnector);
    myTerminalWidget.start();

    processHandler.addProcessListener(new ProcessAdapter() {
      @Override
      public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
        if (attachToProcessOutput) {
          try {
            ConsoleViewContentType contentType = null;
            if (outputType != ProcessOutputTypes.STDOUT) {
              contentType = ConsoleViewContentType.getConsoleViewType(outputType);
            }

            String text = event.getText();
            if (outputType == ProcessOutputTypes.SYSTEM) {
              text = StringUtil.convertLineSeparators(text, LineSeparator.CRLF.getSeparatorString());
            }
            else if (shouldConvertLfToCrlf(processHandler)) {
              text = convertTextToCRLF(text);
            }
            printText(text, contentType);
          }
          catch (IOException e) {
            LOG.info(e);
          }
        }
      }

      @Override
      public void processTerminated(@NotNull ProcessEvent event) {
        myAttachedToProcess.set(false);
        ApplicationManager.getApplication().invokeLater(() -> {
          myTerminalWidget.getTerminalPanel().setCursorVisible(false);
        }, ModalityState.any());
      }
    });
  }
public final void attachToProcess(@NotNull ProcessHandler processHandler,
                                    @NotNull TtyConnector ttyConnector,
                                    boolean attachToProcessOutput)