try {
Position[] positions= event.getDocument().getPositions(fCategory);
for (int i= 0; i != positions.length; i++) {
Position position= positions[i];
if (position.isDeleted())
continue;
int posOffset = position.getOffset();
int posLength = position.getLength(); // always zero
int posEnd = posOffset + posLength;
//System.out.printf(" position %s offset:%d\n", position.toString(), posOffset);
if (posOffset > eventOldEndOffset) {
// position comes way after change - shift
position.setOffset(posOffset + deltaLength);
} else if (posOffset < eventOffset) {
// position comes way before change - leave alone
} else {
// position is within replaced text -
if (fGravity == RIGHT_GRAVITY)
position.setOffset(eventNewEndOffset);
else
position.setOffset(eventOffset);
}
//System.out.printf(" position %s offset:%d\n", position.toString(), position.getOffset());
}
} catch (BadPositionCategoryException e) {
// ignore and return