private static String getTextForField(FieldRange fieldRange, FieldPanel panel) {
		FieldLocation startLoc = fieldRange.getStart();
		BigInteger index = startLoc.getIndex();
		int fieldNum = startLoc.fieldNum;
		int startRow = startLoc.row;
		int startCol = startLoc.col;
		FieldLocation endLoc = fieldRange.getEnd();
		int endRow = endLoc.row;
		int endCol = endLoc.col;

		Layout layout = panel.getLayoutModel().getLayout(index);
		if (layout == null) {
			return null;
		}
		Field field = layout.getField(fieldNum);
		if (field == null) {
			return null;
		}
		String text = field.getText();
		if (text == null) {
			return null;
		}
		int startPos = field.screenLocationToTextOffset(startRow, startCol);
		int endPos = field.screenLocationToTextOffset(endRow, endCol);
		if (startPos < 0 || startPos >= text.length() || endPos < 0 || endPos > text.length()) {
			return null;
		}
		return text.substring(startPos, endPos);
	}
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