public static List<FieldElement> wrap(FieldElement fieldElement, int width,
			boolean breakOnWhiteSpace) {

		if (breakOnWhiteSpace) {
			return wrap(fieldElement, width);
		}

		List<FieldElement> lines = new ArrayList<>();
		if (fieldElement.getStringWidth() <= width) {
			lines.add(fieldElement);
			return lines;
		}

		FieldElement element = fieldElement;
		int wordWrapPos = element.getMaxCharactersForWidth(width);
		if (wordWrapPos == element.length()) {
			wordWrapPos = 0;
		}

		while (wordWrapPos > 0) {
			lines.add(element.substring(0, wordWrapPos));
			element = element.substring(wordWrapPos);
			wordWrapPos = element.getMaxCharactersForWidth(width);
			if (wordWrapPos == element.length()) {
				wordWrapPos = 0;
			}
		}
		lines.add(element);
		return lines;
	}
Splits the given FieldElement into sub-elements by wrapping the element in some fashion.
If breakOnWhiteSpace is indicated, wrapping will break lines on a white space character
if possible, otherwise wrapping occurs on the last possible character.
@param fieldElement is the element to wrap
@param width is the maximum width to allow before wrapping
@param breakOnWhiteSpace determines whether line breaks should happen at white space chars
@return the wrapped elements
Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/FieldUtils.java