本文整理汇总了C#中ICSharpCode.AvalonEdit.Document.DocumentChangeEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DocumentChangeEventArgs类的具体用法?C# DocumentChangeEventArgs怎么用?C# DocumentChangeEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentChangeEventArgs类属于ICSharpCode.AvalonEdit.Document命名空间,在下文中一共展示了DocumentChangeEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
void ILineTracker.ChangeComplete(DocumentChangeEventArgs e)
{
ILineTracker targetTracker = targetObject.Target as ILineTracker;
if (targetTracker != null)
targetTracker.ChangeComplete(e);
else
Deregister();
}
示例2: DocumentOnChanged
private void DocumentOnChanged(object sender, DocumentChangeEventArgs e)
{
SetCurrent();
var textChangeRange = new TextChangeRange(
new TextSpan(e.Offset, e.RemovalLength),
e.RemovalLength == 0 ? e.InsertionLength : e.RemovalLength);
OnTextChanged(new TextChangeEventArgs(_before, CurrentText, textChangeRange));
}
示例3: UpdateOnDocumentChange
/// <inheritdoc/>
public override Selection UpdateOnDocumentChange(DocumentChangeEventArgs e)
{
if (e == null)
throw new ArgumentNullException("e");
return Selection.Create(
textArea,
new TextViewPosition(textArea.Document.GetLocation(e.GetNewOffset(startOffset, AnchorMovementType.Default)), start.VisualColumn),
new TextViewPosition(textArea.Document.GetLocation(e.GetNewOffset(endOffset, AnchorMovementType.Default)), end.VisualColumn)
);
}
示例4: ChangeComplete
public void ChangeComplete(DocumentChangeEventArgs e)
{
if (_lineNumberRemoved > -1)
{
_bookmarkManager.AdjustLineOffsets(AdjustTypes.Deleted, _lineNumberRemoved, e.RemovalLength);
_lineNumberRemoved = -1;
}
_bookmarkManager.RecalculateOffsets(_textArea, BookmarkType.Breakpoint, 1);
}
示例5: OnAvDocChanged
private void OnAvDocChanged(object sender, DocumentChangeEventArgs e)
{
if (_loading) return;
_version++;
Modified = true;
EventHandler<DocumentChangeEventArgs> handler = Changed;
if (handler != null)
handler(sender, e);
}
示例6: UpdateOnDocumentChange
/// <inheritdoc/>
public override Selection UpdateOnDocumentChange(DocumentChangeEventArgs e)
{
if (e == null)
throw new ArgumentNullException("e");
TextViewPosition newStart = start;
TextViewPosition newEnd = end;
// by changing the existing TextViewPosition, we preserve the VisualColumn (though it might become invalid)
// and the IsAtEndOfLine property.
newStart.Location = textArea.Document.GetLocation(e.GetNewOffset(startOffset, AnchorMovementType.Default));
newEnd.Location = textArea.Document.GetLocation(e.GetNewOffset(endOffset, AnchorMovementType.Default));
return Selection.Create(textArea, newStart, newEnd);
}
示例7: OnDocumentChanged
void OnDocumentChanged(DocumentChangeEventArgs e)
{
foldings.UpdateOffsets(e);
FoldingSection s = foldings.FindFirstSegmentWithStartAfter(e.Offset);
while (s != null && s.StartOffset == e.Offset) {
FoldingSection next = foldings.GetNextSegment(s);
if (s.Length == 0) {
RemoveFolding(s);
}
s = next;
}
}
示例8: DocumentOnChanged
private void DocumentOnChanged(object sender, DocumentChangeEventArgs e)
{
if (_updatding) return;
var oldText = _currentText;
var textSpan = new TextSpan(e.Offset, e.RemovalLength);
var textChangeRange = new TextChangeRange(textSpan, e.InsertionLength);
_currentText = _currentText.WithChanges(new TextChange(textSpan, e.InsertedText?.Text ?? string.Empty));
TextChanged?.Invoke(this, new TextChangeEventArgs(oldText, _currentText, textChangeRange));
}
示例9: OnDocumentChanged
void OnDocumentChanged(DocumentChangeEventArgs e)
{
foldings.UpdateOffsets(e);
int newEndOffset = e.Offset + e.InsertionLength;
// extend end offset to the end of the line (including delimiter)
var endLine = document.GetLineByOffset(newEndOffset);
newEndOffset = endLine.Offset + endLine.TotalLength;
foreach (var affectedFolding in foldings.FindOverlappingSegments(e.Offset, newEndOffset - e.Offset)) {
if (affectedFolding.Length == 0) {
RemoveFolding(affectedFolding);
} else {
affectedFolding.ValidateCollapsedLineSections();
}
}
}
示例10: UpdateOnDocumentChange
/// <inheritdoc/>
public override Selection UpdateOnDocumentChange(DocumentChangeEventArgs e)
{
if (e == null)
throw new ArgumentNullException("e");
int newStartOffset, newEndOffset;
if (startOffset <= endOffset) {
newStartOffset = e.GetNewOffset(startOffset, AnchorMovementType.Default);
newEndOffset = Math.Max(newStartOffset, e.GetNewOffset(endOffset, AnchorMovementType.BeforeInsertion));
} else {
newEndOffset = e.GetNewOffset(endOffset, AnchorMovementType.Default);
newStartOffset = Math.Max(newEndOffset, e.GetNewOffset(startOffset, AnchorMovementType.BeforeInsertion));
}
return Selection.Create(
textArea,
new TextViewPosition(textArea.Document.GetLocation(newStartOffset), start.VisualColumn),
new TextViewPosition(textArea.Document.GetLocation(newEndOffset), end.VisualColumn)
);
}
示例11: OnDocumentChanged
internal void OnDocumentChanged(DocumentChangeEventArgs e)
{
InvalidateVisualColumn();
if (storedCaretOffset >= 0) {
int newCaretOffset = e.GetNewOffset(storedCaretOffset, AnchorMovementType.Default);
TextDocument document = textArea.Document;
if (document != null) {
// keep visual column
this.Position = new TextViewPosition(document.GetLocation(newCaretOffset), position.VisualColumn);
}
}
storedCaretOffset = -1;
}
示例12: Push
internal void Push(TextDocument document, DocumentChangeEventArgs e)
{
if (state == StatePlayback)
throw new InvalidOperationException("Document changes during undo/redo operations are not allowed.");
if (state == StatePlaybackModifyDocument)
state = StatePlayback; // allow only 1 change per expected modification
else
Push(new DocumentChangeOperation(document, e));
}
示例13: textArea_Document_Changing
void textArea_Document_Changing(object sender, DocumentChangeEventArgs e)
{
if (e.Offset + e.RemovalLength == this.StartOffset && e.RemovalLength > 0) {
Close(); // removal immediately in front of completion segment: close the window
// this is necessary when pressing backspace after dot-completion
}
if (e.Offset == StartOffset && e.RemovalLength == 0 && ExpectInsertionBeforeStart) {
StartOffset = e.GetNewOffset(StartOffset, AnchorMovementType.AfterInsertion);
this.ExpectInsertionBeforeStart = false;
} else {
StartOffset = e.GetNewOffset(StartOffset, AnchorMovementType.BeforeInsertion);
}
EndOffset = e.GetNewOffset(EndOffset, AnchorMovementType.AfterInsertion);
}
示例14: DoReplace
void DoReplace(int offset, int length, string newText, OffsetChangeMap offsetChangeMap)
{
if (length == 0 && newText.Length == 0)
return;
// trying to replace a single character in 'Normal' mode?
// for single characters, 'CharacterReplace' mode is equivalent, but more performant
// (we don't have to touch the anchorTree at all in 'CharacterReplace' mode)
if (length == 1 && newText.Length == 1 && offsetChangeMap == null)
offsetChangeMap = OffsetChangeMap.Empty;
string removedText = rope.ToString(offset, length);
DocumentChangeEventArgs args = new DocumentChangeEventArgs(offset, removedText, newText, offsetChangeMap);
// fire DocumentChanging event
if (Changing != null)
Changing(this, args);
cachedText = null; // reset cache of complete document text
fireTextChanged = true;
DelayedEvents delayedEvents = new DelayedEvents();
lock (lockObject) {
// create linked list of checkpoints, if required
if (currentCheckpoint != null) {
currentCheckpoint = currentCheckpoint.Append(args);
}
// now update the textBuffer and lineTree
if (offset == 0 && length == rope.Length) {
// optimize replacing the whole document
rope.Clear();
rope.InsertText(0, newText);
lineManager.Rebuild();
} else {
rope.RemoveRange(offset, length);
lineManager.Remove(offset, length);
#if DEBUG
lineTree.CheckProperties();
#endif
rope.InsertText(offset, newText);
lineManager.Insert(offset, newText);
#if DEBUG
lineTree.CheckProperties();
#endif
}
}
// update text anchors
if (offsetChangeMap == null) {
anchorTree.HandleTextChange(args.CreateSingleChangeMapEntry(), delayedEvents);
} else {
foreach (OffsetChangeMapEntry entry in offsetChangeMap) {
anchorTree.HandleTextChange(entry, delayedEvents);
}
}
// raise delayed events after our data structures are consistent again
delayedEvents.RaiseEvents();
// fire DocumentChanged event
if (Changed != null)
Changed(this, args);
}
示例15: document_Changed
void document_Changed(object sender, DocumentChangeEventArgs e)
{
if (DocumentChanged != null)
DocumentChanged(this, e);
}