public String getTextBeforeCursor(int field) {
			if (field == -1) {
				throw new IllegalArgumentException("" + field);
			}
			StringBuilder result = new StringBuilder();
			for (int i = 0; i < field; i++) {
				if (i > 0) {
					result.append(linkedFields.get(i - 1).sep);
				}
				result.append(fieldStates.get(i).text);
			}

			if (field > 0) {
				result.append(linkedFields.get(field - 1).sep);
			}
			FieldState fs = fieldStates.get(field);
			result.append(fs.text.substring(0, Math.min(fs.caret, fs.text.length())));
			return result.toString();
		}
Get the composite text preceding the caret in the given field

@param field the field whose caret to use
@return the text
Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/TextFieldLinker.java