public override bool DeletePrevious() { if (TextView.Selection.IsEmpty) { if (AdvancedCaret.InVirtualSpace) { AdvancedCaret.MoveToPreviousCaretPosition(); } else { if (!CaretPoint.DeletePrevious()) { return(false); } if (AdvancedCaret.InVirtualSpace) { AdvancedCaret.MoveTo(AdvancedCaret.Position.BufferPosition); } } } else { if (!TextView.Selection.Delete()) { return(false); } } AdvancedCaret.EnsureVisible(); return(true); }
public override void MoveToEndOfViewLine(bool extendSelection) { VirtualSnapshotPoint oldCaretPoint = this.AdvancedCaret.Position.VirtualBufferPosition; SnapshotPoint selectionEnd = this.TextView.Selection.AdvancedSelection.End.Position; bool selectionIsEmpty = TextView.Selection.IsEmpty; if (!extendSelection) { TextView.AdvancedTextView.Selection.Clear(); } if (!selectionIsEmpty && !extendSelection) { var selectionEndLine = this.TextView.AdvancedTextView.GetTextViewLineContainingBufferPosition(selectionEnd); AdvancedCaret.MoveTo(selectionEndLine.End, PositionAffinity.Predecessor); } else { ITextViewLine line = this.AdvancedCaret.ContainingTextViewLine; AdvancedCaret.MoveTo(line.End, line.IsLastTextViewLineForSnapshotLine ? PositionAffinity.Successor : PositionAffinity.Predecessor); } AdvancedCaret.EnsureVisible(); UpdateSelection(extendSelection, oldCaretPoint); }
public override void MoveToLine(int lineNumber) { DisplayTextPoint caretLocation = CaretPoint; TextView.Selection.Clear(); caretLocation.MoveToLine(lineNumber); AdvancedCaret.MoveTo(caretLocation.AdvancedTextPoint); AdvancedCaret.EnsureVisible(); }
public override void MoveToStartOfDocument(bool extendSelection) { VirtualSnapshotPoint oldCaretPoint = this.AdvancedCaret.Position.VirtualBufferPosition; if (!extendSelection) { TextView.AdvancedTextView.Selection.Clear(); } AdvancedCaret.MoveTo(new SnapshotPoint(TextView.AdvancedTextView.TextSnapshot, 0)); AdvancedCaret.EnsureVisible(); UpdateSelection(extendSelection, oldCaretPoint); }
public override void MoveTo(int position, bool extendSelection) { VirtualSnapshotPoint oldCaretPoint = this.AdvancedCaret.Position.VirtualBufferPosition; SnapshotPoint bufferPosition = new SnapshotPoint(TextView.AdvancedTextView.TextSnapshot, position); if (!extendSelection) { TextView.AdvancedTextView.Selection.Clear(); } AdvancedCaret.MoveTo(bufferPosition); AdvancedCaret.EnsureVisible(); this.UpdateSelection(extendSelection, oldCaretPoint); }
public override void MoveToPreviousWord(bool extendSelection) { VirtualSnapshotPoint oldCaretPoint = this.AdvancedCaret.Position.VirtualBufferPosition; DisplayTextPoint caretLocation = CaretPoint; if (!extendSelection) { TextView.AdvancedTextView.Selection.Clear(); } caretLocation.MoveToPreviousWord(); AdvancedCaret.MoveTo(caretLocation.AdvancedTextPoint); AdvancedCaret.EnsureVisible(); UpdateSelection(extendSelection, oldCaretPoint); }
public override void MoveToLine(int lineNumber, int offset, bool extendSelection) { VirtualSnapshotPoint oldCaretPoint = this.AdvancedCaret.Position.VirtualBufferPosition; if (!extendSelection) { TextView.AdvancedTextView.Selection.Clear(); } ITextSnapshotLine line = TextView.AdvancedTextView.TextSnapshot.GetLineFromLineNumber(lineNumber); AdvancedCaret.MoveTo(new VirtualSnapshotPoint(line, offset)); AdvancedCaret.EnsureVisible(); UpdateSelection(extendSelection, oldCaretPoint); }
public override bool TransposeLine() { if (TextView.Selection.IsEmpty) { TextPoint caretPoint = CaretPoint; double oldLeft = AdvancedCaret.Left; if (!caretPoint.TransposeLine()) { return(false); } AdvancedCaret.MoveTo(caretPoint.AdvancedTextPoint, PositionAffinity.Successor, false); AdvancedCaret.EnsureVisible(); ITextViewLine newLine = AdvancedTextViewLine; AdvancedCaret.MoveTo(newLine, oldLeft); AdvancedCaret.EnsureVisible(); } return(true); }
private void PageUpDown(ScrollDirection direction) { if (direction == ScrollDirection.Up) { //If we scrolled a full page, then the bottom of the first fully visible line will be below //the bottom of the view. ITextViewLine firstVisibleLine = TextView.AdvancedTextView.TextViewLines.FirstVisibleLine; SnapshotPoint oldFullyVisibleStart = (firstVisibleLine.VisibilityState == VisibilityState.FullyVisible) ? firstVisibleLine.Start : firstVisibleLine.EndIncludingLineBreak; //Start of next line. if (TextView.AdvancedTextView.ViewScroller.ScrollViewportVerticallyByPage(direction)) { ITextViewLine newFirstLine = TextView.AdvancedTextView.TextViewLines.GetTextViewLineContainingBufferPosition(oldFullyVisibleStart); //The old fully visible line should -- if we scrolled as much as we could -- be partially //obscured. The shortfall between a full page and what we actually scrolled is the distance //between the bottom of that line and the bottom of the screen. if (TextView.AdvancedTextView.ViewportBottom > newFirstLine.Bottom) { AdvancedCaret.MoveTo(TextView.AdvancedTextView.TextViewLines.FirstVisibleLine); } else { AdvancedCaret.MoveToPreferredCoordinates(); } } } else { //If we scroll a full page, the bottom of the last fully visible line will be //positioned at 0.0. ITextViewLine lastVisibleLine = TextView.AdvancedTextView.TextViewLines.LastVisibleLine; // If the last line in the buffer is fully visible , then just move the caret to // the last visible line if ((lastVisibleLine.VisibilityState == VisibilityState.FullyVisible) && (lastVisibleLine.End == lastVisibleLine.Snapshot.Length)) { AdvancedCaret.MoveTo(lastVisibleLine); // No need to ensure the caret is visible since the line it just moved to is fully visible. return; } SnapshotPoint oldFullyVisibleStart = ((lastVisibleLine.VisibilityState == VisibilityState.FullyVisible) || (lastVisibleLine.Start == 0)) ? lastVisibleLine.Start : (lastVisibleLine.Start - 1); //Actually just a point on the previous line. if (TextView.AdvancedTextView.ViewScroller.ScrollViewportVerticallyByPage(direction)) { ITextViewLine newLastLine = TextView.AdvancedTextView.TextViewLines.GetTextViewLineContainingBufferPosition(oldFullyVisibleStart); if (newLastLine.Bottom > TextView.AdvancedTextView.ViewportTop) { AdvancedCaret.MoveTo(TextView.AdvancedTextView.TextViewLines.LastVisibleLine); } else { AdvancedCaret.MoveToPreferredCoordinates(); } } } EnsureVisible(); }