ent.update(len, undoEdit.getLFCount()); ent.update(-len, -undoEdit.getLFCount());
/** * Get the document offset of the first LF contained in the * inserted/removed text or -1 for no LFs. This value is not cached. */ int getFirstLFOffset() { if (getLFCount() <= 0) { return -1; } int flfOffset; if (chars != null) { // chars valid valid flfOffset = Analyzer.findFirstLFOffset(chars, 0, chars.length); } else { // string valid flfOffset = Analyzer.findFirstLFOffset(text); } if (flfOffset >= 0) { flfOffset += offset; // shift by the insert/update offset } return flfOffset; }
/** * This function is called after document removal to update marks. Event * parameter contains removed chars and also how many lines was removed. */ synchronized void removeUpdate(ModifyUndoEdit undoEdit) { docLen -= undoEdit.getLength(); marks.update(undoEdit.getOffset(), undoEdit.getLine(), -undoEdit.getLength(), -undoEdit.getLFCount()); update(true, undoEdit); }
/** * This function is called after document insertion to update marks. Event * parameter contains inserted chars and also how many lines was inserted. */ synchronized void insertUpdate(ModifyUndoEdit undoEdit) { docLen += undoEdit.getLength(); marks.update(undoEdit.getOffset(), 0, undoEdit.getLength(), undoEdit.getLFCount()); update(false, undoEdit); }
/** * Get the count of '\n' (line-feeds) contained in the inserted/removed * text. */ public int getLFCount() { return (getModifyUndoEdit() != null) ? getModifyUndoEdit().getLFCount() : 0; }