private int adjustCharacterOffsetForBytesField(FieldLocation fieldLoc, int characterOffset) {

		// Make sure the position is valid
		BigInteger index = fieldLoc.getIndex();
		if ((index.compareTo(BigInteger.ZERO) < 0) ||
			(index.compareTo(layoutModel.getNumIndexes()) >= 0)) {
			return characterOffset;
		}

		Layout layout = layoutModel.getLayout(index);
		if (layout == null) {
			return characterOffset;
		}

		int column = fieldLoc.getCol() + characterOffset;
		int fieldNum = fieldLoc.getFieldNum();
		int fieldRow = fieldLoc.getRow();
		ByteField field = (ByteField) layout.getField(fieldNum);
		if (field != null) {
			// not sure this can be null
			int numCols = field.getNumCols(fieldRow);
			if (column >= numCols) {
				column = numCols - 1;
			}
		}

		return column;
	}
Set the cursor location; called in response to a location change event

@param block the block
@param index the index
@param characterOffset the offset into the UI field
@return index of the location; return -1 if there was an error setting the cursor location
Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java