public class DocumentEventImpl extends DocumentEvent
Constructor and Description |
---|
DocumentEventImpl(Document document,
int offset,
java.lang.CharSequence oldString,
java.lang.CharSequence newString,
long oldTimeStamp,
boolean wholeTextReplaced) |
DocumentEventImpl(Document document,
int offset,
java.lang.CharSequence oldString,
java.lang.CharSequence newString,
long oldTimeStamp,
boolean wholeTextReplaced,
int initialStartOffset,
int initialOldLength,
int moveOffset) |
Modifier and Type | Method and Description |
---|---|
int |
getInitialOldLength() |
int |
getInitialStartOffset() |
int |
getMoveOffset()
In case of any document modifications other than moving text, this method returns the same as
DocumentEvent.getOffset() . |
java.lang.CharSequence |
getNewFragment() |
int |
getNewLength() |
int |
getOffset()
The start offset of a text change.
|
java.lang.CharSequence |
getOldFragment() |
int |
getOldLength() |
long |
getOldTimeStamp() |
boolean |
isWholeTextReplaced() |
java.lang.String |
toString() |
int |
translateLineViaDiff(int line) |
int |
translateLineViaDiffStrict(int line) |
getDocument
public DocumentEventImpl(Document document, int offset, java.lang.CharSequence oldString, java.lang.CharSequence newString, long oldTimeStamp, boolean wholeTextReplaced)
public DocumentEventImpl(Document document, int offset, java.lang.CharSequence oldString, java.lang.CharSequence newString, long oldTimeStamp, boolean wholeTextReplaced, int initialStartOffset, int initialOldLength, int moveOffset)
public int getOffset()
DocumentEvent
getOffset
in class DocumentEvent
public int getOldLength()
getOldLength
in class DocumentEvent
public int getNewLength()
getNewLength
in class DocumentEvent
public java.lang.CharSequence getOldFragment()
getOldFragment
in class DocumentEvent
public java.lang.CharSequence getNewFragment()
getNewFragment
in class DocumentEvent
public int getInitialStartOffset()
Document.replaceString(int, int, CharSequence)
call, before common prefix and
suffix were removed from the changed range.public int getInitialOldLength()
Document.replaceString(int, int, CharSequence)
call, before common prefix and
suffix were removed from the changed range.public int getMoveOffset()
DocumentEvent
DocumentEvent.getOffset()
.
Moving a text fragment using DocumentEx.moveText(int, int, int)
is accomplished by a combination of
insertion and deletion. For these two events this method returns the offset of the complementary deletion/insertion event: DocumentListener.documentChanged(com.intellij.openapi.editor.event.DocumentEvent)
of the insertion event, and
b) during DocumentListener.beforeDocumentChange(com.intellij.openapi.editor.event.DocumentEvent)
of the deletion event.
In order to obtain an adjusted value before the new fragment is inserted or after deleting the original one, consider using
the DocumentEventUtil.getMoveOffsetBeforeInsertion(com.intellij.openapi.editor.event.DocumentEvent)
and the DocumentEventUtil.getMoveOffsetAfterDeletion(com.intellij.openapi.editor.event.DocumentEvent)
methods, accordingly.
Examples:
Moving text to the left:
document.moveText(2, 6, 0); // aa^^^^bb -> ^^^^aa^^^^bb -> ^^^^aabbIn this example the following listener calls are performed:
beforeDocumentChange(insert): aa^^^^bb [ offset: 0, oldLength: 0, newLength: 4, moveOffset: 6, moveOffsetBeforeInsertion: 2 ] documentChanged(insert): ^^^^aa^^^^bb [ offset: 0, oldLength: 0, newLength: 4, moveOffset: 6 ] // moveOffset == delete.offset beforeDocumentChange(delete): ^^^^aa^^^^bb [ offset: 6, oldLength: 4, newLength: 0, moveOffset: 0 ] // moveOffset == insert.offset documentChanged(delete): ^^^^aabb [ offset: 6, oldLength: 4, newLength: 0, moveOffset: 0, moveOffsetAfterDeletion: 0 ]Moving text to the right:
document.moveText(2, 6, 8); // aa^^^^bb -> aa^^^^bb^^^^ -> aabb^^^^In this example the following listener calls are performed:
beforeDocumentChange(insert): aa^^^^bb [ offset: 8, oldLength: 0, newLength: 4, moveOffset: 2, moveOffsetBeforeInsertion: 2 ] documentChanged(insert): aa^^^^bb^^^^ [ offset: 8, oldLength: 0, newLength: 4, moveOffset: 2 ] // moveOffset == delete.offset beforeDocumentChange(delete): aa^^^^bb^^^^ [ offset: 2, oldLength: 4, newLength: 0, moveOffset: 8 ] // moveOffset == insert.offset documentChanged(delete): aabb^^^^ [ offset: 2, oldLength: 4, newLength: 0, moveOffset: 8, moveOffsetAfterDeletion: 4 ]
getMoveOffset
in class DocumentEvent
public long getOldTimeStamp()
getOldTimeStamp
in class DocumentEvent
public java.lang.String toString()
toString
in class java.util.EventObject
public boolean isWholeTextReplaced()
isWholeTextReplaced
in class DocumentEvent
public int translateLineViaDiff(int line) throws FilesTooBigForDiffException
FilesTooBigForDiffException
public int translateLineViaDiffStrict(int line) throws FilesTooBigForDiffException
FilesTooBigForDiffException