public static String getAllSelectedText(FieldSelection selection, FieldPanel panel) {
		StringBuilder buffy = new StringBuilder();
		int numRanges = selection.getNumRanges();
		for (int i = 0; i < numRanges; i++) {
			FieldRange fieldRange = selection.getFieldRange(i);
			buffy.append(getTextForRange(fieldRange, panel));
			if (i != numRanges - 1) {
				buffy.append(' ');
			}
		}

		// remove any whitespace on the ends, as it doesn't offer any value to text selections
		return buffy.toString().trim();
	}
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