/// <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"); } return(new SimpleSelection( e.GetNewOffset(startOffset, AnchorMovementType.AfterInsertion), e.GetNewOffset(endOffset, AnchorMovementType.AfterInsertion) )); }
/// <inheritdoc/> public override Selection UpdateOnDocumentChange(DocumentChangeEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(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) )); }
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) { 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)); }
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; }
private void TextArea_Document_Changing(object sender, DocumentChangeEventArgs e) { if (e.Offset + e.RemovalLength == StartOffset && e.RemovalLength > 0) { Hide(); // 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); 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 + e.RemovalLength == StartOffset && e.RemovalLength > 0) { if (TextArea.Selection.Length == 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); ExpectInsertionBeforeStart = false; } else { StartOffset = e.GetNewOffset(StartOffset, AnchorMovementType.BeforeInsertion); } if (TextArea.Selection.Length > 0) { InsertingIntoSelection = true; EndOffset = StartOffset + e.InsertionLength; int selectStart = TextArea.Document.GetOffset(TextArea.Selection.StartPosition.Location); int selectEnd = TextArea.Document.GetOffset(TextArea.Selection.EndPosition.Location); if (selectStart < selectEnd) { EndOffset--; StartOffset--; } } else { InsertingIntoSelection = false; EndOffset = e.GetNewOffset(EndOffset, AnchorMovementType.AfterInsertion); } }
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; }
/// <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) { return(new RectangleSelection(document, e.GetNewOffset(StartOffset, AnchorMovementType.AfterInsertion), e.GetNewOffset(EndOffset, AnchorMovementType.BeforeInsertion))); }