void (@NotNull ToolWindow toolWindow, @NotNull TerminalWidget widget, @NotNull Content content) { MoveTerminalToolWindowTabLeftAction moveTabLeftAction = new MoveTerminalToolWindowTabLeftAction(); MoveTerminalToolWindowTabRightAction moveTabRightAction = new MoveTerminalToolWindowTabRightAction(); widget.getTerminalTitle().addTitleListener(new TerminalTitleListener() { @Override public void onTitleChanged(@NotNull TerminalTitle terminalTitle) { ApplicationManager.getApplication().invokeLater(() -> { updateTabTitle(terminalTitle, toolWindow, content); }, myProject.getDisposed()); } }, content); JBTerminalWidget terminalWidget = JBTerminalWidget.asJediTermWidget(widget); if (terminalWidget == null) return; terminalWidget.setListener(new JBTerminalWidgetListener() { @Override public void onNewSession() { newTab(toolWindow, null); } @Override public void onTerminalStarted() { } @Override public void onPreviousTabSelected() { if (toolWindow.getContentManager().getContentCount() > 1) { toolWindow.getContentManager().selectPreviousContent(); } } @Override public void onNextTabSelected() { if (toolWindow.getContentManager().getContentCount() > 1) { toolWindow.getContentManager().selectNextContent(); } } @Override public void onSessionClosed() { getContainer(terminalWidget).closeAndHide(); } @Override public void showTabs() { ShowContentAction action = new ShowContentAction(toolWindow, toolWindow.getComponent(), toolWindow.getContentManager()); DataContext dataContext = DataManager.getInstance().getDataContext(toolWindow.getComponent()); KeyEvent fakeKeyEvent = new KeyEvent(toolWindow.getComponent(), ActionEvent.ACTION_PERFORMED, System.currentTimeMillis(), 0, 0, '\0'); AnActionEvent event = AnActionEvent.createFromInputEvent(fakeKeyEvent, ActionPlaces.UNKNOWN, null, dataContext); action.actionPerformed(event); } @Override public void moveTabRight() { moveTabRightAction.move(content, myProject); } @Override public void moveTabLeft() { moveTabLeftAction.move(content, myProject); } @Override public boolean canMoveTabRight() { return moveTabRightAction.isAvailable(content); } @Override public boolean canMoveTabLeft() { return moveTabLeftAction.isAvailable(content); } @Override public boolean canSplit(boolean vertically) { return true; } @Override public void split(boolean vertically) { TerminalToolWindowManager.this.split(widget, vertically); } @Override public boolean isGotoNextSplitTerminalAvailable() { return isSplitTerminal(terminalWidget); } @Override public void gotoNextSplitTerminal(boolean forward) { TerminalToolWindowManager.this.gotoNextSplitTerminal(widget, forward); } }); }