/// <summary> /// Scrolls to the specified line/column. /// This method requires that the TextEditor was already assigned a size (WPF layout must have run prior). /// </summary> public void ScrollTo(int line, int column) { const double MinimumScrollPercentage = 0.3; TextView textView = textArea.TextView; TextDocument document = textView.Document; if (scrollViewer != null && document != null) { if (line < 1) { line = 1; } if (line > document.LineCount) { line = document.LineCount; } IScrollInfo scrollInfo = textView; if (!scrollInfo.CanHorizontallyScroll) { // Word wrap is enabled. Ensure that we have up-to-date info about line height so that we scroll // to the correct position. // This avoids that the user has to repeat the ScrollTo() call several times when there are very long lines. VisualLine vl = textView.GetOrConstructVisualLine(document.GetLineByNumber(line)); double remainingHeight = scrollViewer.ViewportHeight / 2; while (remainingHeight > 0) { DocumentLine prevLine = vl.FirstDocumentLine.PreviousLine; if (prevLine == null) { break; } vl = textView.GetOrConstructVisualLine(prevLine); remainingHeight -= vl.Height; } } Point p = textArea.TextView.GetVisualPosition(new TextViewPosition(line, Math.Max(1, column)), VisualYPosition.LineMiddle); double verticalPos = p.Y - scrollViewer.ViewportHeight / 2; if (Math.Abs(verticalPos - scrollViewer.VerticalOffset) > MinimumScrollPercentage * scrollViewer.ViewportHeight) { scrollViewer.ScrollToVerticalOffset(Math.Max(0, verticalPos)); } if (column > 0) { if (p.X > scrollViewer.ViewportWidth - Caret.MinimumDistanceToViewBorder * 2) { double horizontalPos = Math.Max(0, p.X - scrollViewer.ViewportWidth / 2); if (Math.Abs(horizontalPos - scrollViewer.HorizontalOffset) > MinimumScrollPercentage * scrollViewer.ViewportWidth) { scrollViewer.ScrollToHorizontalOffset(horizontalPos); } } else { scrollViewer.ScrollToHorizontalOffset(0); } } } }
/// <summary> /// Validates the visual column of the caret using the specified visual line. /// The visual line must contain the caret offset. /// </summary> void RevalidateVisualColumn(VisualLine visualLine) { if (visualLine == null) { throw new ArgumentNullException("visualLine"); } // mark column as validated visualColumnValid = true; int caretOffset = textView.Document.GetOffset(position); int firstDocumentLineOffset = visualLine.FirstDocumentLine.Offset; if (position.VisualColumn < 0) { position.VisualColumn = visualLine.GetVisualColumn(caretOffset - firstDocumentLineOffset); } else { int offsetFromVisualColumn = visualLine.GetRelativeOffset(position.VisualColumn); offsetFromVisualColumn += firstDocumentLineOffset; if (offsetFromVisualColumn != caretOffset) { position.VisualColumn = visualLine.GetVisualColumn(caretOffset - firstDocumentLineOffset); } else { if (position.VisualColumn > visualLine.VisualLength) { position.VisualColumn = visualLine.VisualLength; } } } // search possible caret positions int newVisualColumnForwards = visualLine.GetNextCaretPosition(position.VisualColumn - 1, LogicalDirection.Forward, CaretPositioningMode.Normal); // If position.VisualColumn was valid, we're done with validation. if (newVisualColumnForwards != position.VisualColumn) { // also search backwards so that we can pick the better match int newVisualColumnBackwards = visualLine.GetNextCaretPosition(position.VisualColumn + 1, LogicalDirection.Backward, CaretPositioningMode.Normal); if (newVisualColumnForwards < 0 && newVisualColumnBackwards < 0) { throw ThrowUtil.NoValidCaretPosition(); } // determine offsets for new visual column positions int newOffsetForwards; if (newVisualColumnForwards >= 0) { newOffsetForwards = visualLine.GetRelativeOffset(newVisualColumnForwards) + firstDocumentLineOffset; } else { newOffsetForwards = -1; } int newOffsetBackwards; if (newVisualColumnBackwards >= 0) { newOffsetBackwards = visualLine.GetRelativeOffset(newVisualColumnBackwards) + firstDocumentLineOffset; } else { newOffsetBackwards = -1; } int newVisualColumn, newOffset; // if there's only one valid position, use it if (newVisualColumnForwards < 0) { newVisualColumn = newVisualColumnBackwards; newOffset = newOffsetBackwards; } else if (newVisualColumnBackwards < 0) { newVisualColumn = newVisualColumnForwards; newOffset = newOffsetForwards; } else { // two valid positions: find the better match if (Math.Abs(newOffsetBackwards - caretOffset) < Math.Abs(newOffsetForwards - caretOffset)) { // backwards is better newVisualColumn = newVisualColumnBackwards; newOffset = newOffsetBackwards; } else { // forwards is better newVisualColumn = newVisualColumnForwards; newOffset = newOffsetForwards; } } this.Position = new TextViewPosition(textView.Document.GetLocation(newOffset), newVisualColumn); } }
static void MoveCaretRight(TextArea textArea, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode) { int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Forward, mode, textArea.Selection.EnableVirtualSpace); if (pos >= 0) { SetCaretPosition(textArea, pos, visualLine.GetRelativeOffset(pos) + visualLine.FirstDocumentLine.Offset); } else { // move to start of next line DocumentLine nextDocumentLine = visualLine.LastDocumentLine.NextLine; if (nextDocumentLine != null) { VisualLine nextLine = textArea.TextView.GetOrConstructVisualLine(nextDocumentLine); pos = nextLine.GetNextCaretPosition(-1, LogicalDirection.Forward, mode, textArea.Selection.EnableVirtualSpace); if (pos < 0) { throw ThrowUtil.NoValidCaretPosition(); } SetCaretPosition(textArea, pos, nextLine.GetRelativeOffset(pos) + nextLine.FirstDocumentLine.Offset); } else { // at end of document Debug.Assert(visualLine.LastDocumentLine.Offset + visualLine.LastDocumentLine.TotalLength == textArea.Document.TextLength); SetCaretPosition(textArea, -1, textArea.Document.TextLength); } } }
static void MoveCaretUpDown(TextArea textArea, CaretMovementType direction, VisualLine visualLine, TextLine textLine, int caretVisualColumn) { // moving up/down happens using the desired visual X position double xPos = textArea.Caret.DesiredXPos; if (double.IsNaN(xPos)) { xPos = visualLine.GetTextLineVisualXPosition(textLine, caretVisualColumn); } // now find the TextLine+VisualLine where the caret will end up in VisualLine targetVisualLine = visualLine; TextLine targetLine; int textLineIndex = visualLine.TextLines.IndexOf(textLine); switch (direction) { case CaretMovementType.LineUp: { // Move up: move to the previous TextLine in the same visual line // or move to the last TextLine of the previous visual line int prevLineNumber = visualLine.FirstDocumentLine.LineNumber - 1; if (textLineIndex > 0) { targetLine = visualLine.TextLines[textLineIndex - 1]; } else if (prevLineNumber >= 1) { DocumentLine prevLine = textArea.Document.GetLineByNumber(prevLineNumber); targetVisualLine = textArea.TextView.GetOrConstructVisualLine(prevLine); targetLine = targetVisualLine.TextLines[targetVisualLine.TextLines.Count - 1]; } else { targetLine = null; } break; } case CaretMovementType.LineDown: { // Move down: move to the next TextLine in the same visual line // or move to the first TextLine of the next visual line int nextLineNumber = visualLine.LastDocumentLine.LineNumber + 1; if (textLineIndex < visualLine.TextLines.Count - 1) { targetLine = visualLine.TextLines[textLineIndex + 1]; } else if (nextLineNumber <= textArea.Document.LineCount) { DocumentLine nextLine = textArea.Document.GetLineByNumber(nextLineNumber); targetVisualLine = textArea.TextView.GetOrConstructVisualLine(nextLine); targetLine = targetVisualLine.TextLines[0]; } else { targetLine = null; } break; } case CaretMovementType.PageUp: case CaretMovementType.PageDown: { // Page up/down: find the target line using its visual position double yPos = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.LineMiddle); if (direction == CaretMovementType.PageUp) { yPos -= textArea.TextView.RenderSize.Height; } else { yPos += textArea.TextView.RenderSize.Height; } DocumentLine newLine = textArea.TextView.GetDocumentLineByVisualTop(yPos); targetVisualLine = textArea.TextView.GetOrConstructVisualLine(newLine); targetLine = targetVisualLine.GetTextLineByVisualYPosition(yPos); break; } default: throw new NotSupportedException(direction.ToString()); } if (targetLine != null) { double yPos = targetVisualLine.GetTextLineVisualYPosition(targetLine, VisualYPosition.LineMiddle); int newVisualColumn = targetVisualLine.GetVisualColumn(new Point(xPos, yPos), textArea.Selection.EnableVirtualSpace); SetCaretPosition(textArea, targetVisualLine, targetLine, newVisualColumn, false); textArea.Caret.DesiredXPos = xPos; } }
private double GetVisualPos(VisualLine vl, TextLine tl, double pixelHeight) { double pos = vl.GetTextLineVisualYPosition(tl, VisualYPosition.TextMiddle) - TextView.VerticalOffset; return(PixelSnapHelpers.PixelAlign(pos, pixelHeight)); }
private void DrawDebug() { foreach (VisualLine obj in debugLines) { obj.Destroy(); } debugLines.Clear(); if (data.GetDataGeneral().showHelp) { if (line != null) { float lineWidth = .04f; // Take every bubble and draw debug lines from it to the line to help display what's going on. foreach (VisualBubble bubble in trackedBubbles) { if (bubble.visual != null) { DataPoint closestPoint = Utils.GetClosestPointOnLine(line.Start(), line.End(), bubble.Position); float triggerRadius = bubble.Radius; bool isHit = Utils.IsLineTouchingCircle(line.Start(), line.End(), bubble.Position, triggerRadius, GameCore.bubbleRadiusStandard); bool isIntermediate = Utils.IsInRadiusLineRange(line.Start(), line.End(), bubble.Position, triggerRadius); if (closestPoint.IsRealNumber()) { Color color = Color.HSVToRGB(1, .8f, .8f); if (isIntermediate) { color = Color.HSVToRGB(.66f, .8f, .8f); } if (isHit) { color = Color.HSVToRGB(.33f, .8f, .8f); } VisualLine visual = lineManager.CreateLine(bubble.Position, closestPoint, color, lineWidth); debugLines.Add(visual); } } if (bubble.Radius > (GameCore.bubbleRadiusStandard + VisualLineManager.width / 2 + GameCore.widthLeeway) + 0.001f) { DataPoint[] pos = GameCore.DetermineSplits(new DataBubble(bubble.Position, new DataPoint(), speed: 0, BubbleType.Large), line.Start(), line.End()); foreach (DataPoint point in pos) { debugLines.AddRange(lineManager.CreatePlus(point, Color.white)); } } } // Draw extensions on the line itself Vector2 directionUnscaled = new Vector2(line.End().X - line.Start().X, line.End().Y - line.Start().Y); Vector2 direction = directionUnscaled.normalized; Color col = new Color(.3f, .3f, .3f, .03f); float length = 50f; debugLines.Add(lineManager.CreateLine(line.Start(), line.Start() + new DataPoint(-direction * length), col, lineWidth)); debugLines.Add(lineManager.CreateLine(line.End(), line.End() + new DataPoint(direction * length), col, lineWidth)); } // Screen boundary debugging DataPoint screenSize = inputManager.ScreenSizeWorld(); Color borderColor = new Color(1f, .7f, .8f); float borderThickness = 0.1f; debugLines.Add(lineManager.CreateLine(new DataPoint(-screenSize.X, screenSize.Y), new DataPoint(-screenSize.X, -screenSize.Y), borderColor, borderThickness)); // left debugLines.Add(lineManager.CreateLine(new DataPoint(screenSize.X, screenSize.Y), new DataPoint(screenSize.X, -screenSize.Y), borderColor, borderThickness)); // right debugLines.Add(lineManager.CreateLine(new DataPoint(-screenSize.X, screenSize.Y), new DataPoint(screenSize.X, screenSize.Y), borderColor, borderThickness)); // top debugLines.Add(lineManager.CreateLine(new DataPoint(-screenSize.X, -screenSize.Y), new DataPoint(screenSize.X, -screenSize.Y), borderColor, borderThickness)); // bottom } }
private static TextViewPosition GetStartOfLineCaretPosition(int oldVisualColumn, VisualLine visualLine, TextLine textLine, bool enableVirtualSpace) { var newVisualCol = visualLine.GetTextLineVisualStartColumn(textLine); if (newVisualCol == 0) { newVisualCol = visualLine.GetNextCaretPosition(newVisualCol - 1, LogicalDirection.Forward, CaretPositioningMode.WordStart, enableVirtualSpace); } if (newVisualCol < 0) { throw ThrowUtil.NoValidCaretPosition(); } // when the caret is already at the start of the text, jump to start before whitespace if (newVisualCol == oldVisualColumn) { newVisualCol = 0; } return(visualLine.GetTextViewPosition(newVisualCol)); }
static TextViewPosition GetUpDownCaretPosition(TextView textView, TextViewPosition caretPosition, CaretMovementType direction, VisualLine visualLine, TextLine textLine, bool enableVirtualSpace, ref double xPos) { // moving up/down happens using the desired visual X position if (double.IsNaN(xPos)) { xPos = visualLine.GetTextLineVisualXPosition(textLine, caretPosition.VisualColumn); } // now find the TextLine+VisualLine where the caret will end up in VisualLine targetVisualLine = visualLine; TextLine targetLine; int textLineIndex = visualLine.TextLines.IndexOf(textLine); switch (direction) { case CaretMovementType.LineUp: { // Move up: move to the previous TextLine in the same visual line // or move to the last TextLine of the previous visual line int prevLineNumber = visualLine.FirstDocumentLine.LineNumber - 1; if (textLineIndex > 0) { targetLine = visualLine.TextLines[textLineIndex - 1]; } else if (prevLineNumber >= 1) { DocumentLine prevLine = textView.Document.GetLineByNumber(prevLineNumber); targetVisualLine = textView.GetOrConstructVisualLine(prevLine); targetLine = targetVisualLine.TextLines[targetVisualLine.TextLines.Count - 1]; } else { targetLine = null; } break; } case CaretMovementType.LineDown: { // Move down: move to the next TextLine in the same visual line // or move to the first TextLine of the next visual line int nextLineNumber = visualLine.LastDocumentLine.LineNumber + 1; if (textLineIndex < visualLine.TextLines.Count - 1) { targetLine = visualLine.TextLines[textLineIndex + 1]; } else if (nextLineNumber <= textView.Document.LineCount) { DocumentLine nextLine = textView.Document.GetLineByNumber(nextLineNumber); targetVisualLine = textView.GetOrConstructVisualLine(nextLine); targetLine = targetVisualLine.TextLines[0]; } else { targetLine = null; } break; } case CaretMovementType.PageUp: case CaretMovementType.PageDown: { // Page up/down: find the target line using its visual position double yPos = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.LineMiddle); if (direction == CaretMovementType.PageUp) { yPos -= textView.RenderSize.Height; } else { yPos += textView.RenderSize.Height; } DocumentLine newLine = textView.GetDocumentLineByVisualTop(yPos); targetVisualLine = textView.GetOrConstructVisualLine(newLine); targetLine = targetVisualLine.GetTextLineByVisualYPosition(yPos); break; } default: throw new NotSupportedException(direction.ToString()); } if (targetLine != null) { double yPos = targetVisualLine.GetTextLineVisualYPosition(targetLine, VisualYPosition.LineMiddle); int newVisualColumn = targetVisualLine.GetVisualColumn(new Point(xPos, yPos), enableVirtualSpace); // prevent wrapping to the next line; TODO: could 'IsAtEnd' help here? int targetLineStartCol = targetVisualLine.GetTextLineVisualStartColumn(targetLine); if (newVisualColumn >= targetLineStartCol + targetLine.Length) { if (newVisualColumn <= targetVisualLine.VisualLength) { newVisualColumn = targetLineStartCol + targetLine.Length - 1; } } return(targetVisualLine.GetTextViewPosition(newVisualColumn)); } else { return(caretPosition); } }
static TextViewPosition GetPrevCaretPosition(TextView textView, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode, bool enableVirtualSpace) { int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Backward, mode, enableVirtualSpace); if (pos >= 0) { return(visualLine.GetTextViewPosition(pos)); } var previousDocumentLine = visualLine.FirstDocumentLine.PreviousLine; if (previousDocumentLine != null) { var previousLine = textView.GetOrConstructVisualLine(previousDocumentLine); pos = previousLine.GetNextCaretPosition(previousLine.VisualLength + 1, LogicalDirection.Backward, mode, enableVirtualSpace); return(previousLine.GetTextViewPosition(pos)); } return(new TextViewPosition(0, 0)); }
internal static TextViewPosition GetNewCaretPosition(TextView textView, TextViewPosition caretPosition, CaretMovementType direction, bool enableVirtualSpace, ref double desiredXPos) { switch (direction) { case CaretMovementType.None: return(caretPosition); case CaretMovementType.DocumentStart: desiredXPos = double.NaN; return(new TextViewPosition(0, 0)); case CaretMovementType.DocumentEnd: desiredXPos = double.NaN; return(new TextViewPosition(textView.Document.GetLocation(textView.Document.TextLength))); } DocumentLine caretLine = textView.Document.GetLineByNumber(caretPosition.Line); VisualLine visualLine = textView.GetOrConstructVisualLine(caretLine); TextLine textLine = visualLine.GetTextLine(caretPosition.VisualColumn, caretPosition.IsAtEndOfLine); switch (direction) { case CaretMovementType.CharLeft: desiredXPos = double.NaN; // do not move caret to previous line in virtual space if (caretPosition.VisualColumn == 0 && enableVirtualSpace) { return(caretPosition); } return(GetPrevCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.Normal, enableVirtualSpace)); case CaretMovementType.Backspace: desiredXPos = double.NaN; return(GetPrevCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.EveryCodepoint, enableVirtualSpace)); case CaretMovementType.CharRight: desiredXPos = double.NaN; return(GetNextCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.Normal, enableVirtualSpace)); case CaretMovementType.WordLeft: desiredXPos = double.NaN; return(GetPrevCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.WordStart, enableVirtualSpace)); case CaretMovementType.WordRight: desiredXPos = double.NaN; return(GetNextCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.WordStart, enableVirtualSpace)); case CaretMovementType.LineUp: case CaretMovementType.LineDown: case CaretMovementType.PageUp: case CaretMovementType.PageDown: return(GetUpDownCaretPosition(textView, caretPosition, direction, visualLine, textLine, enableVirtualSpace, ref desiredXPos)); case CaretMovementType.LineStart: desiredXPos = double.NaN; return(GetStartOfLineCaretPosition(caretPosition.VisualColumn, visualLine, textLine, enableVirtualSpace)); case CaretMovementType.LineEnd: desiredXPos = double.NaN; return(GetEndOfLineCaretPosition(visualLine, textLine)); default: throw new NotSupportedException(direction.ToString()); } }
/// <summary> /// Creates a visual line text element with the specified length. /// It uses the <see cref="ITextRunConstructionContext.VisualLine"/> and its /// <see cref="VisualLineElement.RelativeTextOffset"/> to find the actual text string. /// </summary> public ColorVisualLineText(string text, VisualLine parentVisualLine, int length, Brush foregroundBrush) : base(parentVisualLine, length) { Text = text; ForegroundBrush = foregroundBrush; }
public HexColorVisualLineText(string hexColor, VisualLine parentVisualLine, int length) : base(parentVisualLine, length) { _hexColor = hexColor; }
private void OnLineCreated(DataPoint start, DataPoint end) { line = lineManager.CreateLine(start, end); }
static TextViewPosition GetNextCaretPosition(TextView textView, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode, bool enableVirtualSpace) { int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Forward, mode, enableVirtualSpace); if (pos >= 0) { return(visualLine.GetTextViewPosition(pos)); } else { // move to start of next line DocumentLine nextDocumentLine = visualLine.LastDocumentLine.NextLine; if (nextDocumentLine != null) { VisualLine nextLine = textView.GetOrConstructVisualLine(nextDocumentLine); pos = nextLine.GetNextCaretPosition(-1, LogicalDirection.Forward, mode, enableVirtualSpace); if (pos < 0) { throw ThrowUtil.NoValidCaretPosition(); } return(nextLine.GetTextViewPosition(pos)); } else { // at end of document Debug.Assert(visualLine.LastDocumentLine.Offset + visualLine.LastDocumentLine.TotalLength == textView.Document.TextLength); return(new TextViewPosition(textView.Document.GetLocation(textView.Document.TextLength))); } } }
double GetVisualPos(VisualLine vl, TextLine tl) { double pos = vl.GetTextLineVisualYPosition(tl, VisualYPosition.LineTop) + tl.Height / 2 - TextView.VerticalOffset; return(Math.Round(pos) + 0.5); }
static TextViewPosition GetPrevCaretPosition(TextView textView, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode, bool enableVirtualSpace) { int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Backward, mode, enableVirtualSpace); if (pos >= 0) { return(visualLine.GetTextViewPosition(pos)); } else { // move to end of previous line DocumentLine previousDocumentLine = visualLine.FirstDocumentLine.PreviousLine; if (previousDocumentLine != null) { VisualLine previousLine = textView.GetOrConstructVisualLine(previousDocumentLine); pos = previousLine.GetNextCaretPosition(previousLine.VisualLength + 1, LogicalDirection.Backward, mode, enableVirtualSpace); if (pos < 0) { throw ThrowUtil.NoValidCaretPosition(); } return(previousLine.GetTextViewPosition(pos)); } else { // at start of document Debug.Assert(visualLine.FirstDocumentLine.Offset == 0); return(new TextViewPosition(0, 0)); } } }
public void TransformLine(TextView textView, DrawingContext drawingContext, VisualLine line) { }
public UppercaseText(VisualLine parentVisualLine, int length) : base(parentVisualLine, length) { }
/// <summary> /// Creates a visual line text element with the specified length. /// It uses the <see cref="ITextRunConstructionContext.VisualLine"/> and its /// <see cref="VisualLineElement.RelativeTextOffset"/> to find the actual text string. /// </summary> public VisualLineMessageViewLinkText(VisualLine parentVisualLine, int length) : base(parentVisualLine, length) { this.RequireControlModifierForClick = false; }
/// <summary> /// Creates a visual line text element with the specified length. /// It uses the <see cref="ITextRunConstructionContext.VisualLine"/> and its /// <see cref="VisualLineElement.RelativeTextOffset"/> to find the actual text string. /// </summary> public VisualLineReferenceText(VisualLine parentVisualLine, int length, ReferenceElementGenerator parent, ReferenceSegment referenceSegment) : base(parentVisualLine, length) { this.parent = parent; this.referenceSegment = referenceSegment; }
public static void ScrollToAvalonEdit(this ScrollViewer scrollViewer, TextArea textArea, int line, int column, VisualYPosition yPositionMode, double referencedVerticalViewPortOffset, double minimumScrollFraction) { TextView textView = textArea.TextView; TextDocument document = textView.Document; if (scrollViewer == null || document == null) { return; } if (line < 1) { line = 1; } if (line > document.LineCount) { line = document.LineCount; } if (!((System.Windows.Controls.Primitives.IScrollInfo)textView).CanHorizontallyScroll) { VisualLine orConstructVisualLine = textView.GetOrConstructVisualLine(document.GetLineByNumber(line)); for (double num = referencedVerticalViewPortOffset; num > 0.0; num -= orConstructVisualLine.Height) { DocumentLine previousLine = orConstructVisualLine.FirstDocumentLine.PreviousLine; if (previousLine == null) { break; } orConstructVisualLine = textView.GetOrConstructVisualLine(previousLine); } } Point visualPosition = textArea.TextView.GetVisualPosition(new TextViewPosition(line, Math.Max(1, column)), yPositionMode); double num2 = visualPosition.Y - referencedVerticalViewPortOffset; if (Math.Abs(num2 - scrollViewer.VerticalOffset) > minimumScrollFraction * scrollViewer.ViewportHeight) { scrollViewer.AnimateScroll(Math.Max(0.0, num2)); } if (column <= 0) { return; } if (visualPosition.X > scrollViewer.ViewportWidth - 60.0) { double num3 = Math.Max(0.0, visualPosition.X - scrollViewer.ViewportWidth / 2.0); if (Math.Abs(num3 - scrollViewer.HorizontalOffset) > minimumScrollFraction * scrollViewer.ViewportWidth) { scrollViewer.ScrollToHorizontalOffset(num3); } } else { scrollViewer.AnimateScroll(0.0); } }