private static String getTextForRange(FieldRange fieldRange, FieldPanel panel) {
		FieldLocation startLoc = fieldRange.getStart();
		FieldLocation endLoc = fieldRange.getEnd();
		BigInteger startIndex = startLoc.getIndex();
		int startFieldNumber = startLoc.fieldNum;
		BigInteger endIndex = endLoc.getIndex();

		StringBuilder buffy = new StringBuilder();
		for (BigInteger i = startIndex; i.compareTo(endIndex) <= 0; i = i.add(BigInteger.ONE)) {
			Layout layout = panel.getLayoutModel().getLayout(i);
			String text = null;
			if (i.equals(startIndex)) {
				if (i.equals(endIndex)) {
					// only one index, use the end values
					text =
						getTextForFieldsInLayout(layout, fieldRange, startFieldNumber,
							endLoc.getFieldNum());
				}
				else {
					text =
						getTextForFieldsInLayout(layout, fieldRange, startFieldNumber,
							layout.getNumFields());
				}
			}
			else if (!i.equals(endIndex)) {
				text = getTextForFieldsInLayout(layout, fieldRange, 0, layout.getNumFields());
			}
			else {
				text = getTextForFieldsInLayout(layout, fieldRange, 0, endLoc.getFieldNum());
			}
			buffy.append(text);

			if (!i.equals(endIndex)) {
				buffy.append(' '); // add space between lines
			}
		}
		return buffy.toString();
	}
Returns the text within the given selection.
@param selection the selection
@param panel the field panel
@return the text
Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/FieldSelectionHelper.java