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; }
internal void OnDocumentChanged(DocumentChangeEventArgs e) { InvalidateVisualColumn(); if (storedCaretOffset >= 0) { // If the caret is at the end of a selection, we don't expand the selection if something // is inserted at the end. Thus we also need to keep the caret in front of the insertion. AnchorMovementType caretMovementType; if (!textArea.Selection.IsEmpty && storedCaretOffset == textArea.Selection.SurroundingSegment.EndOffset) caretMovementType = AnchorMovementType.BeforeInsertion; else caretMovementType = AnchorMovementType.Default; int newCaretOffset = e.GetNewOffset(storedCaretOffset, caretMovementType); TextDocument document = textArea.Document; if (document != null) { // keep visual column this.Position = new TextViewPosition(document.GetLocation(newCaretOffset), position.VisualColumn); } } storedCaretOffset = -1; }
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); }
void textArea_Document_Changing(object sender, DocumentChangeEventArgs e) { 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); }
/// <inheritdoc/> public override Selection UpdateOnDocumentChange(DocumentChangeEventArgs e) { TextLocation newStartLocation = textArea.Document.GetLocation(e.GetNewOffset(topLeftOffset, AnchorMovementType.AfterInsertion)); TextLocation newEndLocation = textArea.Document.GetLocation(e.GetNewOffset(bottomRightOffset, AnchorMovementType.BeforeInsertion)); return new RectangleSelection(textArea, new TextViewPosition(newStartLocation, GetVisualColumnFromXPos(newStartLocation.Line, startXPos)), new TextViewPosition(newEndLocation, GetVisualColumnFromXPos(newEndLocation.Line, endXPos))); }
/// <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) ); }
/// <inheritdoc/> public override Selection UpdateOnDocumentChange(DocumentChangeEventArgs e) { if (e == null) throw new ArgumentNullException("e"); return new SimpleSelection( e.GetNewOffset(startOffset, AnchorMovementType.Default), e.GetNewOffset(endOffset, AnchorMovementType.Default) ); }
/// <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); }
void textArea_Document_Changing(object sender, DocumentChangeEventArgs e) { if(e.Offset == StartOffset && e.RemovalLength == 0) StartOffset = e.GetNewOffset(StartOffset, AnchorMovementType.AfterInsertion); else StartOffset = e.GetNewOffset(StartOffset, AnchorMovementType.BeforeInsertion); EndOffset = e.GetNewOffset(EndOffset, AnchorMovementType.AfterInsertion); }
/// <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) ); }
/// <inheritdoc/> public override Selection UpdateOnDocumentChange(DocumentChangeEventArgs e) { return new RectangleSelection(document, e.GetNewOffset(StartOffset, AnchorMovementType.AfterInsertion), e.GetNewOffset(EndOffset, AnchorMovementType.BeforeInsertion)); }