in core/src/com/jediterm/terminal/model/SelectionUtil.java [48:83]
public static String getSelectionText(@NotNull Point selectionStart,
@NotNull Point selectionEnd,
@NotNull TerminalTextBuffer terminalTextBuffer) {
Pair<Point, Point> pair = sortPoints(selectionStart, selectionEnd);
pair.getFirst().y = Math.max(pair.getFirst().y, - terminalTextBuffer.getHistoryLinesCount());
pair = sortPoints(pair.getFirst(), pair.getSecond()); // previous line may have changed the order
Point top = pair.getFirst();
Point bottom = pair.getSecond();
final StringBuilder selectionText = new StringBuilder();
for (int i = top.y; i <= bottom.y; i++) {
TerminalLine line = terminalTextBuffer.getLine(i);
String text = line.getText();
if (i == top.y) {
if (i == bottom.y) {
selectionText.append(processForSelection(text.substring(Math.min(text.length(), top.x), Math.min(text.length(), bottom.x))));
} else {
selectionText.append(processForSelection(text.substring(Math.min(text.length(), top.x))));
}
}
else if (i == bottom.y) {
selectionText.append(processForSelection(text.substring(0, Math.min(text.length(), bottom.x))));
}
else {
selectionText.append(processForSelection(line.getText()));
}
if ((!line.isWrapped() && i < bottom.y) || bottom.x > text.length()) {
selectionText.append("\n");
}
}
return selectionText.toString();
}