String (@NotNull TerminalPanel terminalPanel) { TerminalTextBuffer buffer = terminalPanel.getTerminalTextBuffer(); buffer.lock(); try { TerminalSelection selection = new TerminalSelection( new Point(0, -buffer.getHistoryLinesCount()), new Point(buffer.getWidth(), buffer.getScreenLinesCount() - 1)); Pair<Point, Point> points = selection.pointsForRun(buffer.getWidth()); return SelectionUtil.getSelectionText(points.first, points.second, buffer); } finally { buffer.unlock(); } }